[librsvg] cargo-clippy: use f64:from(foo) instead of "foo as f64"
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] cargo-clippy: use f64:from(foo) instead of "foo as f64"
- Date: Thu, 22 Feb 2018 19:54:42 +0000 (UTC)
commit f23cceb33b0578523f5d956a8c28c7a4821b78a1
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Feb 22 13:01:10 2018 -0600
cargo-clippy: use f64:from(foo) instead of "foo as f64"
rust/src/transform.rs | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
---
diff --git a/rust/src/transform.rs b/rust/src/transform.rs
index 1c93b948..a4ea150d 100644
--- a/rust/src/transform.rs
+++ b/rust/src/transform.rs
@@ -83,22 +83,22 @@ fn parse_transform_function(name: &str, parser: &mut Parser) -> Result<cairo::Ma
fn parse_matrix_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError> {
parser.parse_nested_block(|p| {
- let xx = p.expect_number()? as f64;
+ let xx = f64::from(p.expect_number()?);
optional_comma(p);
- let yx = p.expect_number()? as f64;
+ let yx = f64::from(p.expect_number()?);
optional_comma(p);
- let xy = p.expect_number()? as f64;
+ let xy = f64::from(p.expect_number()?);
optional_comma(p);
- let yy = p.expect_number()? as f64;
+ let yy = f64::from(p.expect_number()?);
optional_comma(p);
- let x0 = p.expect_number()? as f64;
+ let x0 = f64::from(p.expect_number()?);
optional_comma(p);
- let y0 = p.expect_number()? as f64;
+ let y0 = f64::from(p.expect_number()?);
Ok(cairo::Matrix::new(xx, yx, xy, yy, x0, y0))
}).map_err(CssParseError::<()>::basic)
@@ -107,43 +107,43 @@ fn parse_matrix_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeErro
fn parse_translate_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError> {
parser.parse_nested_block(|p| {
- let tx = p.expect_number()?;
+ let tx = f64::from(p.expect_number()?);
- let ty = p.try(|p| -> Result<f32, CssParseError<()>> {
+ let ty = f64::from(p.try(|p| -> Result<f32, CssParseError<()>> {
optional_comma(p);
Ok(p.expect_number()?)
- }).unwrap_or(0.0);
+ }).unwrap_or(0.0));
- Ok(cairo::Matrix::new(1.0, 0.0, 0.0, 1.0, tx as f64, ty as f64))
+ Ok(cairo::Matrix::new(1.0, 0.0, 0.0, 1.0, tx, ty))
}).map_err(CssParseError::<()>::basic)
.map_err(|e| AttributeError::from(e))
}
fn parse_scale_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError> {
parser.parse_nested_block(|p| {
- let x = p.expect_number()?;
+ let x = f64::from(p.expect_number()?);
let y = p.try(|p| -> Result<f32, CssParseError<()>> {
optional_comma(p);
Ok(p.expect_number()?)
- }).unwrap_or(x);
+ }).map(f64::from).unwrap_or(x);
- Ok(cairo::Matrix::new(x as f64, 0.0, 0.0, y as f64, 0.0, 0.0))
+ Ok(cairo::Matrix::new(x, 0.0, 0.0, y, 0.0, 0.0))
}).map_err(CssParseError::<()>::basic)
.map_err(|e| AttributeError::from(e))
}
fn parse_rotate_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError> {
parser.parse_nested_block(|p| {
- let angle = p.expect_number()? as f64 * PI / 180.0;
+ let angle = f64::from(p.expect_number()?) * PI / 180.0;
let (s, c) = angle.sin_cos();
let (tx, ty) = p.try(|p| -> Result<_, CssParseError<()>> {
optional_comma(p);
- let tx = p.expect_number()? as f64;
+ let tx = f64::from(p.expect_number()?);
optional_comma(p);
- let ty = p.expect_number()? as f64;
+ let ty = f64::from(p.expect_number()?);
Ok((tx, ty))
}).unwrap_or((0.0, 0.0));
@@ -159,7 +159,7 @@ fn parse_rotate_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeErro
fn parse_skewx_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError> {
parser.parse_nested_block(|p| {
- let a = p.expect_number()? as f64 * PI / 180.0;
+ let a = f64::from(p.expect_number()?) * PI / 180.0;
Ok(cairo::Matrix::new (1.0, 0.0,
a.tan (), 1.0,
0.0, 0.0))
@@ -169,7 +169,7 @@ fn parse_skewx_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError
fn parse_skewy_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError> {
parser.parse_nested_block(|p| {
- let a = p.expect_number()? as f64 * PI / 180.0;
+ let a = f64::from(p.expect_number()?) * PI / 180.0;
Ok(cairo::Matrix::new (1.0, a.tan (),
0.0, 1.0,
0.0, 0.0))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]