[librsvg] cargo fmt
- From: Jordan Petridis <jpetridis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] cargo fmt
- Date: Wed, 1 Aug 2018 17:40:36 +0000 (UTC)
commit bdea07e225a8ce6933b3d9309f77bdda9417a126
Author: Jordan Petridis <jordanpetridis protonmail com>
Date: Wed Aug 1 20:39:44 2018 +0300
cargo fmt
rsvg_internals/src/aspect_ratio.rs | 4 +--
rsvg_internals/src/coord_units.rs | 3 +-
rsvg_internals/src/drawing_ctx.rs | 5 ++-
rsvg_internals/src/filters/composite.rs | 3 +-
rsvg_internals/src/filters/context.rs | 6 ++--
rsvg_internals/src/filters/merge.rs | 3 +-
rsvg_internals/src/filters/mod.rs | 3 +-
rsvg_internals/src/filters/turbulence.rs | 3 +-
rsvg_internals/src/gradient.rs | 6 ++--
rsvg_internals/src/marker.rs | 39 +++++++++++-----------
rsvg_internals/src/space.rs | 9 ++---
rsvg_internals/src/surface_utils/shared_surface.rs | 6 ++--
rsvg_internals/src/transform.rs | 28 ++++++----------
13 files changed, 50 insertions(+), 68 deletions(-)
---
diff --git a/rsvg_internals/src/aspect_ratio.rs b/rsvg_internals/src/aspect_ratio.rs
index 4dac352f..f7655a04 100644
--- a/rsvg_internals/src/aspect_ratio.rs
+++ b/rsvg_internals/src/aspect_ratio.rs
@@ -160,8 +160,8 @@ impl AspectRatio {
.and_then(|ident| Align::parse_xy(ident))
})?;
- let fit =
- p.try(|p| {
+ let fit = p
+ .try(|p| {
p.expect_ident()
.map_err(|_| ())
.and_then(|ident| FitMode::parse(ident))
diff --git a/rsvg_internals/src/coord_units.rs b/rsvg_internals/src/coord_units.rs
index 333e7f1e..1317baab 100644
--- a/rsvg_internals/src/coord_units.rs
+++ b/rsvg_internals/src/coord_units.rs
@@ -32,8 +32,7 @@ impl Parse for CoordUnits {
cow.as_ref().to_string(),
))),
),
- })
- .map_err(|_| {
+ }).map_err(|_| {
AttributeError::Parse(ParseError::new(
"expected 'userSpaceOnUse' or 'objectBoundingBox'",
))
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index afa8ae71..a76bf063 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -83,7 +83,7 @@ impl<'a> DrawingCtx<'a> {
width,
height,
}.transform(&affine)
- .outer();
+ .outer();
// scale according to size set by size_func callback
let mut scale = cairo::Matrix::identity();
@@ -361,8 +361,7 @@ impl<'a> DrawingCtx<'a> {
)
}
}
- })
- .or(Some(child_surface))
+ }).or(Some(child_surface))
.unwrap();
self.cr = self.cr_stack.pop().unwrap();
diff --git a/rsvg_internals/src/filters/composite.rs b/rsvg_internals/src/filters/composite.rs
index cd1f5cbd..4742e3af 100644
--- a/rsvg_internals/src/filters/composite.rs
+++ b/rsvg_internals/src/filters/composite.rs
@@ -233,8 +233,7 @@ impl Parse for Operator {
cow.as_ref().to_string(),
))),
),
- })
- .map_err(|_| AttributeError::Value("invalid operator value".to_string()))
+ }).map_err(|_| AttributeError::Value("invalid operator value".to_string()))
}
}
diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs
index 6ff22c0d..5938374b 100644
--- a/rsvg_internals/src/filters/context.rs
+++ b/rsvg_internals/src/filters/context.rs
@@ -532,16 +532,14 @@ impl FilterContext {
.and_then(|surface| {
SharedImageSurface::new(surface, SurfaceType::SRgb)
.map_err(FilterError::CairoError)
- })
- .map(FilterInput::StandardInput),
+ }).map(FilterInput::StandardInput),
Input::StrokePaint => self
.get_paint_server_surface(draw_ctx, &values.stroke.0, values.stroke_opacity.0)
.map_err(FilterError::CairoError)
.and_then(|surface| {
SharedImageSurface::new(surface, SurfaceType::SRgb)
.map_err(FilterError::CairoError)
- })
- .map(FilterInput::StandardInput),
+ }).map(FilterInput::StandardInput),
Input::FilterOutput(ref name) => self
.filter_output(name)
diff --git a/rsvg_internals/src/filters/merge.rs b/rsvg_internals/src/filters/merge.rs
index d4ca3c8a..3ecfa23f 100644
--- a/rsvg_internals/src/filters/merge.rs
+++ b/rsvg_internals/src/filters/merge.rs
@@ -143,7 +143,8 @@ impl Filter for Merge {
.filter(|c| c.get_type() == NodeType::FilterPrimitiveMergeNode)
{
bounds = bounds.add_input(
- &child.with_impl(|c: &MergeNode| ctx.get_input(draw_ctx, c.in_.borrow().as_ref()))?,
+ &child
+ .with_impl(|c: &MergeNode| ctx.get_input(draw_ctx, c.in_.borrow().as_ref()))?,
);
}
let bounds = bounds.into_irect(draw_ctx);
diff --git a/rsvg_internals/src/filters/mod.rs b/rsvg_internals/src/filters/mod.rs
index bcb604a2..410fc6be 100644
--- a/rsvg_internals/src/filters/mod.rs
+++ b/rsvg_internals/src/filters/mod.rs
@@ -120,8 +120,7 @@ impl NodeTrait for Primitive {
} else {
None
}
- })
- .unwrap_or(CoordUnits::UserSpaceOnUse);
+ }).unwrap_or(CoordUnits::UserSpaceOnUse);
let no_units_allowed = primitiveunits == CoordUnits::ObjectBoundingBox;
let check_units = |length: Length| {
diff --git a/rsvg_internals/src/filters/turbulence.rs b/rsvg_internals/src/filters/turbulence.rs
index c559fb10..af02ea07 100644
--- a/rsvg_internals/src/filters/turbulence.rs
+++ b/rsvg_internals/src/filters/turbulence.rs
@@ -94,8 +94,7 @@ impl NodeTrait for Turbulence {
f64::from(i32::min_value()),
f64::from(i32::max_value()),
) as i32
- })
- .map_err(|err| NodeError::parse_error(attr, err))?,
+ }).map_err(|err| NodeError::parse_error(attr, err))?,
),
Attribute::StitchTiles => self.stitch_tiles.set(StitchTiles::parse(attr, value)?),
Attribute::Type => self.type_.set(NoiseType::parse(attr, value)?),
diff --git a/rsvg_internals/src/gradient.rs b/rsvg_internals/src/gradient.rs
index 215d956c..109d3621 100644
--- a/rsvg_internals/src/gradient.rs
+++ b/rsvg_internals/src/gradient.rs
@@ -53,8 +53,7 @@ impl Parse for SpreadMethod {
cow.as_ref().to_string(),
))),
),
- })
- .map_err(|_| {
+ }).map_err(|_| {
AttributeError::Parse(ParseError::new("expected 'pad' | 'reflect' | 'repeat'"))
})
}
@@ -437,8 +436,7 @@ fn resolve_gradient(gradient: &Gradient, draw_ctx: &mut DrawingCtx) -> Gradient
result.resolve_from_fallback(&fallback_grad)
});
Some(())
- })
- .or_else(|| {
+ }).or_else(|| {
result.resolve_from_defaults();
Some(())
});
diff --git a/rsvg_internals/src/marker.rs b/rsvg_internals/src/marker.rs
index de636e1f..88b6ca1b 100644
--- a/rsvg_internals/src/marker.rs
+++ b/rsvg_internals/src/marker.rs
@@ -51,8 +51,7 @@ impl Parse for MarkerUnits {
cow.as_ref().to_string(),
))),
),
- })
- .map_err(|_| {
+ }).map_err(|_| {
AttributeError::Parse(ParseError::new(
"expected \"userSpaceOnUse\" or \"strokeWidth\"",
))
@@ -1139,30 +1138,30 @@ mod directionality_tests {
#[test]
fn curve_has_directionality() {
- let (v1x, v1y, v2x, v2y) = super::get_segment_directionalities(&curve(
- 1.0, 2.0, 3.0, 5.0, 8.0, 13.0, 20.0, 33.0,
- )).unwrap();
+ let (v1x, v1y, v2x, v2y) =
+ super::get_segment_directionalities(&curve(1.0, 2.0, 3.0, 5.0, 8.0, 13.0, 20.0, 33.0))
+ .unwrap();
assert_eq!((2.0, 3.0), (v1x, v1y));
assert_eq!((12.0, 20.0), (v2x, v2y));
}
#[test]
fn curves_with_loops_and_coincident_ends_have_directionality() {
- let (v1x, v1y, v2x, v2y) = super::get_segment_directionalities(&curve(
- 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 1.0, 2.0,
- )).unwrap();
+ let (v1x, v1y, v2x, v2y) =
+ super::get_segment_directionalities(&curve(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 1.0, 2.0))
+ .unwrap();
assert_eq!((2.0, 2.0), (v1x, v1y));
assert_eq!((-4.0, -4.0), (v2x, v2y));
- let (v1x, v1y, v2x, v2y) = super::get_segment_directionalities(&curve(
- 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0,
- )).unwrap();
+ let (v1x, v1y, v2x, v2y) =
+ super::get_segment_directionalities(&curve(1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0))
+ .unwrap();
assert_eq!((2.0, 2.0), (v1x, v1y));
assert_eq!((-2.0, -2.0), (v2x, v2y));
- let (v1x, v1y, v2x, v2y) = super::get_segment_directionalities(&curve(
- 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 1.0, 2.0,
- )).unwrap();
+ let (v1x, v1y, v2x, v2y) =
+ super::get_segment_directionalities(&curve(1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 1.0, 2.0))
+ .unwrap();
assert_eq!((2.0, 2.0), (v1x, v1y));
assert_eq!((-2.0, -2.0), (v2x, v2y));
}
@@ -1177,18 +1176,18 @@ mod directionality_tests {
#[test]
fn curve_with_123_coincident_has_directionality() {
- let (v1x, v1y, v2x, v2y) = super::get_segment_directionalities(&curve(
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 40.0,
- )).unwrap();
+ let (v1x, v1y, v2x, v2y) =
+ super::get_segment_directionalities(&curve(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 20.0, 40.0))
+ .unwrap();
assert_eq!((20.0, 40.0), (v1x, v1y));
assert_eq!((20.0, 40.0), (v2x, v2y));
}
#[test]
fn curve_with_234_coincident_has_directionality() {
- let (v1x, v1y, v2x, v2y) = super::get_segment_directionalities(&curve(
- 20.0, 40.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
- )).unwrap();
+ let (v1x, v1y, v2x, v2y) =
+ super::get_segment_directionalities(&curve(20.0, 40.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0))
+ .unwrap();
assert_eq!((-20.0, -40.0), (v1x, v1y));
assert_eq!((-20.0, -40.0), (v2x, v2y));
diff --git a/rsvg_internals/src/space.rs b/rsvg_internals/src/space.rs
index 20ffb326..d61afaad 100644
--- a/rsvg_internals/src/space.rs
+++ b/rsvg_internals/src/space.rs
@@ -28,12 +28,10 @@ fn normalize_default(s: &str) -> String {
.map(|ch| match ch {
'\t' => ' ',
c => c,
- })
- .coalesce(|current, next| match (current, next) {
+ }).coalesce(|current, next| match (current, next) {
(' ', ' ') => Ok(' '),
(_, _) => Err((current, next)),
- })
- .collect::<String>()
+ }).collect::<String>()
}
// From https://www.w3.org/TR/SVG/text.html#WhiteSpace
@@ -52,8 +50,7 @@ fn normalize_preserve(s: &str) -> String {
'\n' | '\t' => ' ',
c => c,
- })
- .collect()
+ }).collect()
}
#[cfg(test)]
diff --git a/rsvg_internals/src/surface_utils/shared_surface.rs
b/rsvg_internals/src/surface_utils/shared_surface.rs
index 8b81ae70..527b6eec 100644
--- a/rsvg_internals/src/surface_utils/shared_surface.rs
+++ b/rsvg_internals/src/surface_utils/shared_surface.rs
@@ -85,9 +85,9 @@ impl SharedImageSurface {
return Err(surface.status());
}
- let data_ptr = NonNull::new(unsafe {
- cairo_sys::cairo_image_surface_get_data(surface.to_raw_none())
- }).unwrap();
+ let data_ptr =
+ NonNull::new(unsafe { cairo_sys::cairo_image_surface_get_data(surface.to_raw_none()) })
+ .unwrap();
let width = surface.get_width();
let height = surface.get_height();
diff --git a/rsvg_internals/src/transform.rs b/rsvg_internals/src/transform.rs
index f8e2c927..b747375d 100644
--- a/rsvg_internals/src/transform.rs
+++ b/rsvg_internals/src/transform.rs
@@ -98,8 +98,7 @@ fn parse_matrix_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeErro
let y0 = f64::from(p.expect_number()?);
Ok(cairo::Matrix::new(xx, yx, xy, yy, x0, y0))
- })
- .map_err(CssParseError::<()>::basic)
+ }).map_err(CssParseError::<()>::basic)
.map_err(AttributeError::from)
}
@@ -116,8 +115,7 @@ fn parse_translate_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeE
);
Ok(cairo::Matrix::new(1.0, 0.0, 0.0, 1.0, tx, ty))
- })
- .map_err(CssParseError::<()>::basic)
+ }).map_err(CssParseError::<()>::basic)
.map_err(AttributeError::from)
}
@@ -126,16 +124,15 @@ 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<()>> {
+ let y = p
+ .try(|p| -> Result<f32, CssParseError<()>> {
optional_comma(p);
Ok(p.expect_number()?)
}).map(f64::from)
- .unwrap_or(x);
+ .unwrap_or(x);
Ok(cairo::Matrix::new(x, 0.0, 0.0, y, 0.0, 0.0))
- })
- .map_err(CssParseError::<()>::basic)
+ }).map_err(CssParseError::<()>::basic)
.map_err(AttributeError::from)
}
@@ -145,8 +142,8 @@ 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<()>> {
+ let (tx, ty) = p
+ .try(|p| -> Result<_, CssParseError<()>> {
optional_comma(p);
let tx = f64::from(p.expect_number()?);
@@ -161,8 +158,7 @@ fn parse_rotate_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeErro
m = cairo::Matrix::multiply(&cairo::Matrix::new(c, s, -s, c, 0.0, 0.0), &m);
m = cairo::Matrix::multiply(&cairo::Matrix::new(1.0, 0.0, 0.0, 1.0, -tx, -ty), &m);
Ok(m)
- })
- .map_err(CssParseError::<()>::basic)
+ }).map_err(CssParseError::<()>::basic)
.map_err(AttributeError::from)
}
@@ -171,8 +167,7 @@ fn parse_skewx_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError
.parse_nested_block(|p| {
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))
- })
- .map_err(CssParseError::<()>::basic)
+ }).map_err(CssParseError::<()>::basic)
.map_err(AttributeError::from)
}
@@ -181,8 +176,7 @@ fn parse_skewy_args(parser: &mut Parser) -> Result<cairo::Matrix, AttributeError
.parse_nested_block(|p| {
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))
- })
- .map_err(CssParseError::<()>::basic)
+ }).map_err(CssParseError::<()>::basic)
.map_err(AttributeError::from)
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]