summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-08-25 11:34:04 +0200
committerLaurenz <laurmaedje@gmail.com>2023-08-25 11:34:04 +0200
commit94df32a91973ace83f5f628db3daa19725be11e3 (patch)
tree1916331f0395a0aa26c3d95ac3cc565c3ba577d8
parentc00fc14905380da2f3eb6ab9bbb366c096c6a6a2 (diff)
Make clippy happy
-rw-r--r--crates/typst/src/image.rs11
-rw-r--r--crates/typst/src/model/styles.rs4
2 files changed, 8 insertions, 7 deletions
diff --git a/crates/typst/src/image.rs b/crates/typst/src/image.rs
index 05672e2a..40dad615 100644
--- a/crates/typst/src/image.rs
+++ b/crates/typst/src/image.rs
@@ -4,6 +4,7 @@ use std::cell::RefCell;
use std::collections::BTreeMap;
use std::fmt::{self, Debug, Formatter};
use std::io;
+use std::rc::Rc;
use std::sync::Arc;
use comemo::{Prehashed, Track, Tracked};
@@ -126,7 +127,7 @@ impl Image {
}
/// The decoded version of the image.
- pub fn decoded(&self) -> Arc<DecodedImage> {
+ pub fn decoded(&self) -> Rc<DecodedImage> {
match self.format() {
ImageFormat::Raster(format) => decode_raster(self.data(), format),
ImageFormat::Vector(VectorFormat::Svg) => {
@@ -265,7 +266,7 @@ pub struct IccProfile(pub Vec<u8>);
/// Decode a raster image.
#[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>>(
decoder: ImageResult<T>,
) -> ImageResult<(image::DynamicImage, Option<IccProfile>)> {
@@ -284,7 +285,7 @@ fn decode_raster(data: &Bytes, format: RasterFormat) -> StrResult<Arc<DecodedIma
}
.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.
@@ -292,7 +293,7 @@ fn decode_raster(data: &Bytes, format: RasterFormat) -> StrResult<Arc<DecodedIma
fn decode_svg(
data: &Bytes,
loader: Tracked<dyn SvgFontLoader + '_>,
-) -> StrResult<Arc<DecodedImage>> {
+) -> StrResult<Rc<DecodedImage>> {
// 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
// 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);
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.
diff --git a/crates/typst/src/model/styles.rs b/crates/typst/src/model/styles.rs
index 3a6a0b98..75172680 100644
--- a/crates/typst/src/model/styles.rs
+++ b/crates/typst/src/model/styles.rs
@@ -42,7 +42,7 @@ impl Styles {
/// Apply outer styles. Like [`chain`](StyleChain::chain), but in-place.
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;
}
@@ -53,7 +53,7 @@ impl Styles {
/// Apply a slice of outer styles.
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.