Skip to content

Commit e18f9b8

Browse files
committed
fix warnings
1 parent 1ab45e7 commit e18f9b8

File tree

7 files changed

+40
-47
lines changed

7 files changed

+40
-47
lines changed

src/object/action.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ pub enum Action {
1111
}
1212

1313
impl Action {
14-
pub(crate) fn serialize(
15-
&self,
16-
_: &mut SerializerContext,
17-
action: pdf_writer::writers::Action,
18-
) {
14+
pub(crate) fn serialize(&self, _: &mut SerializerContext, action: pdf_writer::writers::Action) {
1915
match self {
2016
Action::Link(link) => link.serialize(action),
2117
}

src/object/annotation.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::error::KrillaResult;
44
use crate::object::action::Action;
55
use crate::object::destination::Destination;
6-
use crate::serialize::{Object, SerializerContext};
6+
use crate::serialize::SerializerContext;
77
use crate::util::RectExt;
88
use pdf_writer::types::AnnotationType;
99
use pdf_writer::{Chunk, Finish, Name, Ref};
@@ -70,9 +70,12 @@ impl LinkAnnotation {
7070
annotation.border(0.0, 0.0, 0.0, None);
7171

7272
match &self.target {
73-
Target::Destination(destination) => {
74-
destination.serialize(sc, annotation.insert(Name(b"Dest")).start::<pdf_writer::writers::Destination>())?
75-
}
73+
Target::Destination(destination) => destination.serialize(
74+
sc,
75+
annotation
76+
.insert(Name(b"Dest"))
77+
.start::<pdf_writer::writers::Destination>(),
78+
)?,
7679
Target::Action(action) => action.serialize(sc, annotation.action()),
7780
};
7881

@@ -89,15 +92,12 @@ mod tests {
8992
use crate::object::annotation::{LinkAnnotation, Target};
9093
use crate::object::destination::XyzDestination;
9194

92-
use crate::color::rgb;
93-
use crate::color::rgb::Rgb;
9495
use crate::serialize::SerializeSettings;
9596
use crate::surface::PageBuilder;
9697
use crate::tests::{default_size, green_fill, rect_to_path, red_fill};
97-
use crate::{Fill, Paint};
98+
9899
use krilla_macros::snapshot;
99100
use tiny_skia_path::{Point, Rect, Size};
100-
use usvg::NormalizedF32;
101101

102102
#[snapshot(single_page)]
103103
fn annotation_to_link(page: &mut PageBuilder) {
@@ -143,10 +143,7 @@ mod tests {
143143
);
144144

145145
let mut surface = page.surface();
146-
surface.fill_path(
147-
&rect_to_path(50.0, 0.0, 150.0, 100.0),
148-
red_fill(1.0)
149-
);
146+
surface.fill_path(&rect_to_path(50.0, 0.0, 150.0, 100.0), red_fill(1.0));
150147
surface.finish();
151148
page.finish();
152149

@@ -161,10 +158,7 @@ mod tests {
161158
.into(),
162159
);
163160
let mut my_surface = page.surface();
164-
my_surface.fill_path(
165-
&rect_to_path(50.0, 100.0, 150.0, 200.0),
166-
green_fill(1.0),
167-
);
161+
my_surface.fill_path(&rect_to_path(50.0, 100.0, 150.0, 200.0), green_fill(1.0));
168162

169163
my_surface.finish();
170164
page.finish();

src/object/destination.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//! Destinations in a PDF document.
22
3-
use crate::chunk_container::ChunkContainer;
43
use crate::error::{KrillaError, KrillaResult};
5-
use crate::serialize::{Object, SerializerContext};
6-
use pdf_writer::{Chunk, Ref};
4+
use crate::serialize::SerializerContext;
75
use std::hash::{Hash, Hasher};
86
use tiny_skia_path::{Point, Transform};
97

@@ -15,7 +13,11 @@ pub enum Destination {
1513
}
1614

1715
impl Destination {
18-
pub(crate) fn serialize(&self, sc: &mut SerializerContext, destination: pdf_writer::writers::Destination) -> KrillaResult<()> {
16+
pub(crate) fn serialize(
17+
&self,
18+
sc: &mut SerializerContext,
19+
destination: pdf_writer::writers::Destination,
20+
) -> KrillaResult<()> {
1921
match self {
2022
Destination::Xyz(xyz) => xyz.serialize(sc, destination),
2123
}
@@ -51,7 +53,11 @@ impl XyzDestination {
5153
Self { page_index, point }
5254
}
5355

54-
pub(crate) fn serialize(&self, sc: &mut SerializerContext, mut destination: pdf_writer::writers::Destination) -> KrillaResult<()> {
56+
pub(crate) fn serialize(
57+
&self,
58+
sc: &mut SerializerContext,
59+
destination: pdf_writer::writers::Destination,
60+
) -> KrillaResult<()> {
5561
let page_info = sc
5662
.page_infos()
5763
.get(self.page_index)

src/object/mask.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
///! Creating and using masks.
2-
32
use crate::chunk_container::ChunkContainer;
43
use crate::error::KrillaResult;
54
use crate::object::shading_function::{GradientProperties, ShadingFunction};
@@ -130,11 +129,11 @@ mod tests {
130129
use crate::surface::{StreamBuilder, Surface};
131130

132131
use crate::color::rgb;
132+
use crate::tests::{rect_to_path, red_fill};
133133
use crate::{Fill, MaskType, Paint};
134134
use krilla_macros::{snapshot, visreg};
135135
use tiny_skia_path::{PathBuilder, Rect};
136136
use usvg::NormalizedF32;
137-
use crate::tests::{rect_to_path, red_fill};
138137

139138
fn mask_snapshot_impl(mask_type: MaskType, sc: &mut SerializerContext) {
140139
let mut stream_builder = StreamBuilder::new(sc);
@@ -144,10 +143,7 @@ mod tests {
144143
builder.push_rect(Rect::from_xywh(20.0, 20.0, 160.0, 160.0).unwrap());
145144
let path = builder.finish().unwrap();
146145

147-
surface.fill_path(
148-
&path,
149-
red_fill(0.5),
150-
);
146+
surface.fill_path(&path, red_fill(0.5));
151147
surface.finish();
152148
let mask = Mask::new(stream_builder.finish(), mask_type);
153149
sc.add_object(mask).unwrap();
@@ -156,12 +152,9 @@ mod tests {
156152
fn mask_visreg_impl(mask_type: MaskType, surface: &mut Surface, color: rgb::Color) {
157153
let mut stream_builder = surface.stream_builder();
158154
let mut sub_surface = stream_builder.surface();
159-
let path = rect_to_path(20.0, 20.0, 180.0 ,180.0);
155+
let path = rect_to_path(20.0, 20.0, 180.0, 180.0);
160156

161-
sub_surface.fill_path(
162-
&path,
163-
red_fill(0.2),
164-
);
157+
sub_surface.fill_path(&path, red_fill(0.2));
165158
sub_surface.finish();
166159

167160
let mask = Mask::new(stream_builder.finish(), mask_type);
@@ -187,7 +180,6 @@ mod tests {
187180
mask_visreg_impl(MaskType::Luminosity, surface, rgb::Color::new(0, 255, 0));
188181
}
189182

190-
191183
#[visreg(all)]
192184
pub fn mask_alpha(surface: &mut Surface) {
193185
mask_visreg_impl(MaskType::Luminosity, surface, rgb::Color::new(0, 0, 128));

src/object/outline.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
1818
use crate::error::KrillaResult;
1919
use crate::object::destination::XyzDestination;
20-
use crate::serialize::{Object, SerializerContext};
21-
use pdf_writer::{Chunk, Finish, Name, Ref, TextStr};
20+
use crate::serialize::SerializerContext;
21+
use pdf_writer::{Chunk, Finish, Ref, TextStr};
2222

2323
/// An outline.
2424
///
@@ -100,7 +100,7 @@ pub struct OutlineNode {
100100
/// The text of the outline entry.
101101
text: String,
102102
/// The destination of the outline entry.
103-
destination: XyzDestination
103+
destination: XyzDestination,
104104
}
105105

106106
impl OutlineNode {
@@ -193,10 +193,10 @@ mod tests {
193193
use crate::document::Document;
194194
use crate::object::outline::{Outline, OutlineNode};
195195

196-
use krilla_macros::snapshot;
197-
use tiny_skia_path::{Point, Size};
198196
use crate::destination::XyzDestination;
199197
use crate::tests::{blue_fill, green_fill, rect_to_path, red_fill};
198+
use krilla_macros::snapshot;
199+
use tiny_skia_path::{Point, Size};
200200

201201
#[snapshot(document)]
202202
fn outline_simple(db: &mut Document) {
@@ -212,13 +212,19 @@ mod tests {
212212
}
213213
let mut outline = Outline::new();
214214

215-
let mut child1 = OutlineNode::new("Heading 1".to_string(), XyzDestination::new(0, Point::from_xy(0.0, 0.0)));
215+
let mut child1 = OutlineNode::new(
216+
"Heading 1".to_string(),
217+
XyzDestination::new(0, Point::from_xy(0.0, 0.0)),
218+
);
216219
child1.push_child(OutlineNode::new(
217220
"Heading 1.1".to_string(),
218221
XyzDestination::new(1, Point::from_xy(50.0, 50.0)),
219222
));
220223

221-
let child2 = OutlineNode::new("Heading 2".to_string(), XyzDestination::new(2, Point::from_xy(100.0, 100.0)));
224+
let child2 = OutlineNode::new(
225+
"Heading 2".to_string(),
226+
XyzDestination::new(2, Point::from_xy(100.0, 100.0)),
227+
);
222228

223229
outline.push_child(child1);
224230
outline.push_child(child2);

src/serialize.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ impl SerializerContext {
332332
self.chunk_container.outline = Some((outline_ref, chunk));
333333
}
334334

335-
336335
let fonts = std::mem::take(&mut self.font_map);
337336
for font_container in fonts.values() {
338337
match &*font_container.borrow() {

src/tests/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::color::rgb;
2+
use crate::color::rgb::Rgb;
23
use crate::document::Document;
34
use crate::font::Font;
45
use crate::image::Image;
@@ -18,7 +19,6 @@ use std::env;
1819
use std::path::PathBuf;
1920
use std::sync::{Arc, LazyLock};
2021
use tiny_skia_path::{NormalizedF32, Path, PathBuilder, Point, Rect};
21-
use crate::color::rgb::Rgb;
2222

2323
mod manual;
2424
mod visreg;

0 commit comments

Comments
 (0)