[librsvg] rustfmt
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] rustfmt
- Date: Mon, 21 May 2018 19:13:39 +0000 (UTC)
commit 768a6e88a83088f8b3d4202737aa8a598bfe1837
Author: Federico Mena Quintero <federico gnome org>
Date: Mon May 21 14:13:00 2018 -0500
rustfmt
rsvg_internals/src/aspect_ratio.rs | 11 ++++++-----
rsvg_internals/src/color.rs | 4 +++-
rsvg_internals/src/filters/mod.rs | 6 ++++--
rsvg_internals/src/filters/offset.rs | 7 +++++--
rsvg_internals/src/gradient.rs | 4 +++-
rsvg_internals/src/marker.rs | 29 +++++++++++++++++------------
rsvg_internals/src/path_parser.rs | 19 ++++++++++++-------
rsvg_internals/src/pattern.rs | 14 ++++++++++----
rsvg_internals/src/shapes.rs | 12 ++++++++----
rsvg_internals/src/stop.rs | 4 +++-
rsvg_internals/src/structure.rs | 6 ++++--
rsvg_internals/src/text.rs | 12 ++++++++----
rsvg_internals/src/transform.rs | 36 ++++++++++++++++++++----------------
13 files changed, 103 insertions(+), 61 deletions(-)
---
diff --git a/rsvg_internals/src/aspect_ratio.rs b/rsvg_internals/src/aspect_ratio.rs
index ec601f8e..e8b076e5 100644
--- a/rsvg_internals/src/aspect_ratio.rs
+++ b/rsvg_internals/src/aspect_ratio.rs
@@ -160,11 +160,12 @@ impl AspectRatio {
.and_then(|ident| Align::parse_xy(ident))
})?;
- let fit = p.try(|p| {
- p.expect_ident()
- .map_err(|_| ())
- .and_then(|ident| FitMode::parse(ident))
- }).unwrap_or(FitMode::default());
+ let fit =
+ p.try(|p| {
+ p.expect_ident()
+ .map_err(|_| ())
+ .and_then(|ident| FitMode::parse(ident))
+ }).unwrap_or(FitMode::default());
p.expect_exhausted().map_err(|_| ())?;
diff --git a/rsvg_internals/src/color.rs b/rsvg_internals/src/color.rs
index affc1bca..161c83fa 100644
--- a/rsvg_internals/src/color.rs
+++ b/rsvg_internals/src/color.rs
@@ -69,7 +69,9 @@ pub struct ColorSpec {
}
pub fn rgba_to_argb(rgba: cssparser::RGBA) -> u32 {
- u32::from(rgba.alpha) << 24 | u32::from(rgba.red) << 16 | u32::from(rgba.green) << 8
+ u32::from(rgba.alpha) << 24
+ | u32::from(rgba.red) << 16
+ | u32::from(rgba.green) << 8
| u32::from(rgba.blue)
}
diff --git a/rsvg_internals/src/filters/mod.rs b/rsvg_internals/src/filters/mod.rs
index bfa2f253..cc57b97e 100644
--- a/rsvg_internals/src/filters/mod.rs
+++ b/rsvg_internals/src/filters/mod.rs
@@ -106,9 +106,11 @@ impl NodeTrait for Primitive {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag) -> NodeResult {
for (_key, attr, value) in pbag.iter() {
match attr {
- Attribute::X => self.x
+ Attribute::X => self
+ .x
.set(Some(parse("x", value, LengthDir::Horizontal, None)?)),
- Attribute::Y => self.y
+ Attribute::Y => self
+ .y
.set(Some(parse("y", value, LengthDir::Vertical, None)?)),
Attribute::Width => {
self.width
diff --git a/rsvg_internals/src/filters/offset.rs b/rsvg_internals/src/filters/offset.rs
index e4aa167d..b6598996 100644
--- a/rsvg_internals/src/filters/offset.rs
+++ b/rsvg_internals/src/filters/offset.rs
@@ -48,7 +48,8 @@ impl NodeTrait for Offset {
for (_key, attr, value) in pbag.iter() {
match attr {
- Attribute::Dx => self.dx
+ Attribute::Dx => self
+ .dx
.set(parse("dx", value, LengthDir::Horizontal, None)?),
Attribute::Dy => self.dy.set(parse("dy", value, LengthDir::Vertical, None)?),
_ => (),
@@ -113,7 +114,9 @@ impl Filter for Offset {
for y in bounds.y0..bounds.y1 {
for x in bounds.x0..bounds.x1 {
- if x - ox < bounds.x0 || x - ox >= bounds.x1 || y - oy < bounds.y0
+ if x - ox < bounds.x0
+ || x - ox >= bounds.x1
+ || y - oy < bounds.y0
|| y - oy >= bounds.y1
{
continue;
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 0a24ab92..7d11c4bd 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -159,7 +159,9 @@ impl GradientCommon {
}
fn is_resolved(&self) -> bool {
- self.units.is_some() && self.affine.is_some() && self.spread.is_some()
+ self.units.is_some()
+ && self.affine.is_some()
+ && self.spread.is_some()
&& self.stops.is_some()
}
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index 13f6e897..c2704dd7 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -218,7 +218,8 @@ impl NodeTrait for NodeMarker {
.set(parse("refX", value, LengthDir::Horizontal, None)?)
}
- Attribute::RefY => self.ref_y
+ Attribute::RefY => self
+ .ref_y
.set(parse("refY", value, LengthDir::Vertical, None)?),
Attribute::MarkerWidth => self.width.set(parse(
@@ -826,10 +827,12 @@ mod parser_tests {
#[test]
fn parsing_invalid_marker_units_yields_error() {
- assert!(is_parse_error(&MarkerUnits::parse("", ()).map_err(|e| AttributeError::from(e))));
- assert!(
- is_parse_error(&MarkerUnits::parse("foo", ()).map_err(|e| AttributeError::from(e)))
- );
+ assert!(is_parse_error(
+ &MarkerUnits::parse("", ()).map_err(|e| AttributeError::from(e))
+ ));
+ assert!(is_parse_error(
+ &MarkerUnits::parse("foo", ()).map_err(|e| AttributeError::from(e))
+ ));
}
#[test]
@@ -846,13 +849,15 @@ mod parser_tests {
#[test]
fn parsing_invalid_marker_orient_yields_error() {
- assert!(is_parse_error(&MarkerOrient::parse("", ()).map_err(|e| AttributeError::from(e))));
- assert!(
- is_parse_error(&MarkerOrient::parse("blah", ()).map_err(|e| AttributeError::from(e)))
- );
- assert!(
- is_parse_error(&MarkerOrient::parse("45blah", ()).map_err(|e| AttributeError::from(e)))
- );
+ assert!(is_parse_error(
+ &MarkerOrient::parse("", ()).map_err(|e| AttributeError::from(e))
+ ));
+ assert!(is_parse_error(
+ &MarkerOrient::parse("blah", ()).map_err(|e| AttributeError::from(e))
+ ));
+ assert!(is_parse_error(
+ &MarkerOrient::parse("45blah", ()).map_err(|e| AttributeError::from(e))
+ ));
}
#[test]
diff --git a/rsvg_internals/src/path_parser.rs b/rsvg_internals/src/path_parser.rs
index c1547c6e..df7bbaef 100644
--- a/rsvg_internals/src/path_parser.rs
+++ b/rsvg_internals/src/path_parser.rs
@@ -175,7 +175,9 @@ impl<'b> PathParser<'b> {
fn lookahead_is_start_of_number(&mut self) -> bool {
let mut c = ' ';
- self.lookahead_is_digit(&mut c) || self.lookahead_is('.') || self.lookahead_is('+')
+ self.lookahead_is_digit(&mut c)
+ || self.lookahead_is('.')
+ || self.lookahead_is('+')
|| self.lookahead_is('-')
}
@@ -489,12 +491,15 @@ impl<'b> PathParser<'b> {
}
fn drawto_command(&mut self) -> Result<bool, ParseError> {
- Ok(
- self.close_path()? || self.line_to()? || self.horizontal_line_to()?
- || self.vertical_line_to()? || self.curve_to()?
- || self.smooth_curve_to()? || self.quadratic_bezier_curve_to()?
- || self.smooth_quadratic_bezier_curve_to()? || self.elliptical_arc()?,
- )
+ Ok(self.close_path()?
+ || self.line_to()?
+ || self.horizontal_line_to()?
+ || self.vertical_line_to()?
+ || self.curve_to()?
+ || self.smooth_curve_to()?
+ || self.quadratic_bezier_curve_to()?
+ || self.smooth_quadratic_bezier_curve_to()?
+ || self.elliptical_arc()?)
}
fn close_path(&mut self) -> Result<bool, ParseError> {
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index 9f52cc43..6b5f2fe1 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -109,10 +109,16 @@ impl Pattern {
}
fn is_resolved(&self) -> bool {
- self.units.is_some() && self.content_units.is_some() && self.vbox.is_some()
- && self.preserve_aspect_ratio.is_some() && self.affine.is_some()
- && self.x.is_some() && self.y.is_some() && self.width.is_some()
- && self.height.is_some() && self.children_are_resolved()
+ self.units.is_some()
+ && self.content_units.is_some()
+ && self.vbox.is_some()
+ && self.preserve_aspect_ratio.is_some()
+ && self.affine.is_some()
+ && self.x.is_some()
+ && self.y.is_some()
+ && self.width.is_some()
+ && self.height.is_some()
+ && self.children_are_resolved()
}
fn children_are_resolved(&self) -> bool {
diff --git a/rsvg_internals/src/shapes.rs b/rsvg_internals/src/shapes.rs
index 367e4432..94c7309b 100644
--- a/rsvg_internals/src/shapes.rs
+++ b/rsvg_internals/src/shapes.rs
@@ -242,10 +242,12 @@ impl NodeTrait for NodeLine {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag) -> NodeResult {
for (_key, attr, value) in pbag.iter() {
match attr {
- Attribute::X1 => self.x1
+ Attribute::X1 => self
+ .x1
.set(parse("x1", value, LengthDir::Horizontal, None)?),
Attribute::Y1 => self.y1.set(parse("y1", value, LengthDir::Vertical, None)?),
- Attribute::X2 => self.x2
+ Attribute::X2 => self
+ .x2
.set(parse("x2", value, LengthDir::Horizontal, None)?),
Attribute::Y2 => self.y2.set(parse("y2", value, LengthDir::Vertical, None)?),
_ => (),
@@ -518,7 +520,8 @@ impl NodeTrait for NodeCircle {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag) -> NodeResult {
for (_key, attr, value) in pbag.iter() {
match attr {
- Attribute::Cx => self.cx
+ Attribute::Cx => self
+ .cx
.set(parse("cx", value, LengthDir::Horizontal, None)?),
Attribute::Cy => self.cy.set(parse("cy", value, LengthDir::Vertical, None)?),
Attribute::R => self.r.set(parse(
@@ -578,7 +581,8 @@ impl NodeTrait for NodeEllipse {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag) -> NodeResult {
for (_key, attr, value) in pbag.iter() {
match attr {
- Attribute::Cx => self.cx
+ Attribute::Cx => self
+ .cx
.set(parse("cx", value, LengthDir::Horizontal, None)?),
Attribute::Cy => self.cy.set(parse("cy", value, LengthDir::Vertical, None)?),
diff --git a/rsvg_internals/src/stop.rs b/rsvg_internals/src/stop.rs
index 0151c5bf..aa804c95 100644
--- a/rsvg_internals/src/stop.rs
+++ b/rsvg_internals/src/stop.rs
@@ -138,7 +138,9 @@ impl NodeTrait for NodeStop {
}
fn u32_from_rgba(rgba: cssparser::RGBA) -> u32 {
- (u32::from(rgba.red) << 24) | (u32::from(rgba.green) << 16) | (u32::from(rgba.blue) << 8)
+ (u32::from(rgba.red) << 24)
+ | (u32::from(rgba.green) << 16)
+ | (u32::from(rgba.blue) << 8)
| u32::from(rgba.alpha)
}
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 2c3c8458..eec444b6 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -316,11 +316,13 @@ impl NodeTrait for NodeUse {
// From https://www.w3.org/TR/SVG/struct.html#UseElement in
// "If the ‘use’ element references a ‘symbol’ element"
- let nw = self.w
+ let nw = self
+ .w
.get()
.unwrap_or_else(|| RsvgLength::parse("100%", LengthDir::Horizontal).unwrap())
.normalize(draw_ctx);
- let nh = self.h
+ let nh = self
+ .h
.get()
.unwrap_or_else(|| RsvgLength::parse("100%", LengthDir::Vertical).unwrap())
.normalize(draw_ctx);
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 63c9f5d6..95254675 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -146,7 +146,8 @@ impl NodeTrait for NodeText {
match attr {
Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal, None)?),
Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical, None)?),
- Attribute::Dx => self.dx
+ Attribute::Dx => self
+ .dx
.set(parse("dx", value, LengthDir::Horizontal, None)?),
Attribute::Dy => self.dy.set(parse("dy", value, LengthDir::Vertical, None)?),
_ => (),
@@ -368,11 +369,14 @@ impl NodeTrait for NodeTSpan {
fn set_atts(&self, _: &RsvgNode, _: *const RsvgHandle, pbag: &PropertyBag) -> NodeResult {
for (_key, attr, value) in pbag.iter() {
match attr {
- Attribute::X => self.x
+ Attribute::X => self
+ .x
.set(parse("x", value, LengthDir::Horizontal, None).map(Some)?),
- Attribute::Y => self.y
+ Attribute::Y => self
+ .y
.set(parse("y", value, LengthDir::Vertical, None).map(Some)?),
- Attribute::Dx => self.dx
+ Attribute::Dx => self
+ .dx
.set(parse("dx", value, LengthDir::Horizontal, None)?),
Attribute::Dy => self.dy.set(parse("dy", value, LengthDir::Vertical, None)?),
_ => (),
diff --git a/rsvg_internals/src/transform.rs b/rsvg_internals/src/transform.rs
index 078d2c63..4847463b 100644
--- a/rsvg_internals/src/transform.rs
+++ b/rsvg_internals/src/transform.rs
@@ -111,10 +111,12 @@ fn parse_translate_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeE
.parse_nested_block(|p| {
let tx = f64::from(p.expect_number()?);
- let ty = f64::from(p.try(|p| -> Result<f32, CssParseError<()>> {
- optional_comma(p);
- Ok(p.expect_number()?)
- }).unwrap_or(0.0));
+ let ty = f64::from(
+ p.try(|p| -> Result<f32, CssParseError<()>> {
+ optional_comma(p);
+ Ok(p.expect_number()?)
+ }).unwrap_or(0.0),
+ );
Ok(cairo::Matrix::new(1.0, 0.0, 0.0, 1.0, tx, ty))
})
@@ -127,11 +129,12 @@ fn parse_scale_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError
.parse_nested_block(|p| {
let x = f64::from(p.expect_number()?);
- let y = p.try(|p| -> Result<f32, CssParseError<()>> {
- optional_comma(p);
- Ok(p.expect_number()?)
- }).map(f64::from)
- .unwrap_or(x);
+ let y =
+ p.try(|p| -> Result<f32, CssParseError<()>> {
+ optional_comma(p);
+ Ok(p.expect_number()?)
+ }).map(f64::from)
+ .unwrap_or(x);
Ok(cairo::Matrix::new(x, 0.0, 0.0, y, 0.0, 0.0))
})
@@ -145,15 +148,16 @@ fn parse_rotate_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeErro
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 = f64::from(p.expect_number()?);
+ let (tx, ty) =
+ p.try(|p| -> Result<_, CssParseError<()>> {
+ optional_comma(p);
+ let tx = f64::from(p.expect_number()?);
- optional_comma(p);
- let ty = f64::from(p.expect_number()?);
+ optional_comma(p);
+ let ty = f64::from(p.expect_number()?);
- Ok((tx, ty))
- }).unwrap_or((0.0, 0.0));
+ Ok((tx, ty))
+ }).unwrap_or((0.0, 0.0));
let mut m = cairo::Matrix::new(1.0, 0.0, 0.0, 1.0, tx, ty);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]