Make clippy happy

This commit is contained in:
Laurenz 2023-08-25 11:34:04 +02:00
parent c00fc14905
commit 94df32a919
2 changed files with 8 additions and 7 deletions

View File

@ -4,6 +4,7 @@ use std::cell::RefCell;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::fmt::{self, Debug, Formatter}; use std::fmt::{self, Debug, Formatter};
use std::io; use std::io;
use std::rc::Rc;
use std::sync::Arc; use std::sync::Arc;
use comemo::{Prehashed, Track, Tracked}; use comemo::{Prehashed, Track, Tracked};
@ -126,7 +127,7 @@ impl Image {
} }
/// The decoded version of the image. /// The decoded version of the image.
pub fn decoded(&self) -> Arc<DecodedImage> { pub fn decoded(&self) -> Rc<DecodedImage> {
match self.format() { match self.format() {
ImageFormat::Raster(format) => decode_raster(self.data(), format), ImageFormat::Raster(format) => decode_raster(self.data(), format),
ImageFormat::Vector(VectorFormat::Svg) => { ImageFormat::Vector(VectorFormat::Svg) => {
@ -265,7 +266,7 @@ pub struct IccProfile(pub Vec<u8>);
/// Decode a raster image. /// Decode a raster image.
#[comemo::memoize] #[comemo::memoize]
fn decode_raster(data: &Bytes, format: RasterFormat) -> StrResult<Arc<DecodedImage>> { fn decode_raster(data: &Bytes, format: RasterFormat) -> StrResult<Rc<DecodedImage>> {
fn decode_with<'a, T: ImageDecoder<'a>>( fn decode_with<'a, T: ImageDecoder<'a>>(
decoder: ImageResult<T>, decoder: ImageResult<T>,
) -> ImageResult<(image::DynamicImage, Option<IccProfile>)> { ) -> ImageResult<(image::DynamicImage, Option<IccProfile>)> {
@ -284,7 +285,7 @@ fn decode_raster(data: &Bytes, format: RasterFormat) -> StrResult<Arc<DecodedIma
} }
.map_err(format_image_error)?; .map_err(format_image_error)?;
Ok(Arc::new(DecodedImage::Raster(dynamic, icc, format))) Ok(Rc::new(DecodedImage::Raster(dynamic, icc, format)))
} }
/// Decode an SVG image. /// Decode an SVG image.
@ -292,7 +293,7 @@ fn decode_raster(data: &Bytes, format: RasterFormat) -> StrResult<Arc<DecodedIma
fn decode_svg( fn decode_svg(
data: &Bytes, data: &Bytes,
loader: Tracked<dyn SvgFontLoader + '_>, loader: Tracked<dyn SvgFontLoader + '_>,
) -> StrResult<Arc<DecodedImage>> { ) -> StrResult<Rc<DecodedImage>> {
// Disable usvg's default to "Times New Roman". Instead, we default to // Disable usvg's default to "Times New Roman". Instead, we default to
// the empty family and later, when we traverse the SVG, we check for // the empty family and later, when we traverse the SVG, we check for
// empty and non-existing family names and replace them with the true // empty and non-existing family names and replace them with the true
@ -304,7 +305,7 @@ fn decode_svg(
let fontdb = load_svg_fonts(&tree, loader); let fontdb = load_svg_fonts(&tree, loader);
tree.convert_text(&fontdb); tree.convert_text(&fontdb);
} }
Ok(Arc::new(DecodedImage::Svg(tree))) Ok(Rc::new(DecodedImage::Svg(tree)))
} }
/// Discover and load the fonts referenced by an SVG. /// Discover and load the fonts referenced by an SVG.

View File

@ -42,7 +42,7 @@ impl Styles {
/// Apply outer styles. Like [`chain`](StyleChain::chain), but in-place. /// Apply outer styles. Like [`chain`](StyleChain::chain), but in-place.
pub fn apply(&mut self, mut outer: Self) { pub fn apply(&mut self, mut outer: Self) {
outer.0.extend(mem::take(self).0.into_iter()); outer.0.extend(mem::take(self).0);
*self = outer; *self = outer;
} }
@ -53,7 +53,7 @@ impl Styles {
/// Apply a slice of outer styles. /// Apply a slice of outer styles.
pub fn apply_slice(&mut self, outer: &[Prehashed<Style>]) { pub fn apply_slice(&mut self, outer: &[Prehashed<Style>]) {
self.0 = outer.iter().cloned().chain(mem::take(self).0.into_iter()).collect(); self.0 = outer.iter().cloned().chain(mem::take(self).0).collect();
} }
/// Add an origin span to all contained properties. /// Add an origin span to all contained properties.