Skip to content

Commit d1d67e3

Browse files
authored
Derive Default on enums (#61)
1 parent 3c0337f commit d1d67e3

12 files changed

Lines changed: 70 additions & 34 deletions

src/annotations.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,14 @@ impl AnnotationType {
292292
}
293293

294294
/// Possible icons for an annotation.
295-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
295+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
296296
pub enum AnnotationIcon<'a> {
297297
/// Speech bubble. For use with text annotations.
298298
Comment,
299299
/// For use with text annotations.
300300
Key,
301301
/// Sticky note. For use with text annotations.
302+
#[default]
302303
Note,
303304
/// Question mark or manual. For use with text annotations.
304305
Help,
@@ -525,9 +526,10 @@ deref!('a, AppearanceCharacteristics<'a> => Dict<'a>, dict);
525526

526527
/// The position the text of the widget annotation's caption relative to its
527528
/// icon.
528-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
529+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
529530
pub enum TextPosition {
530531
/// Hide icon, show only caption.
532+
#[default]
531533
CaptionOnly = 0,
532534
/// Hide caption, show only icon.
533535
IconOnly = 1,
@@ -586,9 +588,10 @@ impl IconFit<'_> {
586588
deref!('a, IconFit<'a> => Dict<'a>, dict);
587589

588590
/// How the icon in a push button field should be scaled.
589-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
591+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
590592
pub enum IconScale {
591593
/// Always scale the icon.
594+
#[default]
592595
Always,
593596
/// Scale the icon only when the icon is bigger than the annotation
594597
/// rectangle.
@@ -612,7 +615,7 @@ impl IconScale {
612615
}
613616

614617
/// How the icon in a push button field should be scaled.
615-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
618+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
616619
pub enum IconScaleType {
617620
/// Scale the icon to fill the annotation rectangle exactly, without regard
618621
/// to its original aspect ratio (ratio of width to height).
@@ -622,6 +625,7 @@ pub enum IconScaleType {
622625
/// horizontal and vertical scaling factors are different, use the smaller
623626
/// of the two, centering the icon within the annotation rectangle in the
624627
/// other dimension.
628+
#[default]
625629
Proportional,
626630
}
627631

@@ -636,11 +640,12 @@ impl IconScaleType {
636640

637641
/// Highlighting effect applied when a user holds the mouse button over an
638642
/// annotation.
639-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
643+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
640644
pub enum HighlightEffect {
641645
/// No effect.
642646
None,
643647
/// Invert the colors inside of the annotation rect.
648+
#[default]
644649
Invert,
645650
/// Invert the colors on the annotation border.
646651
Outline,

src/attributes.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,10 @@ impl Placement {
224224
}
225225

226226
/// Writing direction.
227-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
227+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
228228
pub enum WritingMode {
229229
/// Horizontal writing mode, left-to-right.
230+
#[default]
230231
LtrTtb,
231232
/// Horizontal writing mode, right-to-left.
232233
RtlTtb,
@@ -245,9 +246,10 @@ impl WritingMode {
245246
}
246247

247248
/// Layout border style.
248-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
249+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
249250
pub enum LayoutBorderStyle {
250251
/// No border.
252+
#[default]
251253
None,
252254
/// Hidden border.
253255
Hidden,
@@ -340,9 +342,10 @@ impl LayoutAttributes<'_> {
340342
}
341343

342344
/// The text alignment.
343-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
345+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
344346
pub enum TextAlign {
345347
/// At the start of the inline advance direction.
348+
#[default]
346349
Start,
347350
/// Centered.
348351
Center,
@@ -404,9 +407,10 @@ impl LayoutAttributes<'_> {
404407
}
405408

406409
/// The block alignment.
407-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
410+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
408411
pub enum BlockAlign {
409412
/// At the start of the block advance direction.
413+
#[default]
410414
Before,
411415
/// Centered.
412416
Middle,
@@ -449,9 +453,10 @@ impl LayoutAttributes<'_> {
449453
}
450454

451455
/// The inline alignment.
452-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
456+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
453457
pub enum InlineAlign {
454458
/// At the start of the inline advance direction.
459+
#[default]
455460
Start,
456461
/// Centered.
457462
Center,
@@ -513,10 +518,11 @@ impl LayoutAttributes<'_> {
513518
}
514519

515520
/// The height of a line.
516-
#[derive(Debug, Copy, Clone, PartialEq)]
521+
#[derive(Debug, Copy, Clone, Default, PartialEq)]
517522
pub enum LineHeight {
518523
/// Adjust the line height automatically, taking `/BaselineShift` into
519524
/// account.
525+
#[default]
520526
Normal,
521527
/// Adjust the line height automatically.
522528
Auto,
@@ -535,9 +541,10 @@ impl LineHeight {
535541
}
536542

537543
/// Where the text is positioned relative to the baseline.
538-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
544+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
539545
pub enum LayoutTextPosition {
540546
/// At the baseline.
547+
#[default]
541548
Normal,
542549
/// Above the baseline.
543550
Superscript,
@@ -556,9 +563,10 @@ impl LayoutTextPosition {
556563
}
557564

558565
/// The text decoration type (over- and underlines).
559-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
566+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
560567
pub enum TextDecorationType {
561568
/// No decoration.
569+
#[default]
562570
None,
563571
/// Underlined.
564572
Underline,
@@ -605,7 +613,7 @@ impl LayoutAttributes<'_> {
605613
}
606614

607615
/// The alignment of a ruby annotation.
608-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
616+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
609617
pub enum RubyAlign {
610618
/// At the start of the inline advance direction.
611619
Start,
@@ -616,6 +624,7 @@ pub enum RubyAlign {
616624
/// Justified.
617625
Justify,
618626
/// Distribute along the full width of the line with additional space.
627+
#[default]
619628
Distribute,
620629
}
621630

@@ -632,9 +641,10 @@ impl RubyAlign {
632641
}
633642

634643
/// The position of a ruby annotation.
635-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
644+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
636645
pub enum RubyPosition {
637646
/// Before edge of the element.
647+
#[default]
638648
Before,
639649
/// After edge of the element.
640650
After,
@@ -700,9 +710,10 @@ impl<'a> ListAttributes<'a> {
700710
deref!('a, ListAttributes<'a> => Dict<'a>, dict);
701711

702712
/// The list numbering type.
703-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
713+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
704714
pub enum ListNumbering {
705715
/// No numbering.
716+
#[default]
706717
None,
707718
/// An unordered list with unspecified bullets. PDF 2.0+.
708719
Unordered,
@@ -817,9 +828,10 @@ impl FieldRole {
817828
}
818829

819830
/// Whether a check box or radio button is checked.
820-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
831+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
821832
pub enum FieldState {
822833
/// The check box or radio button is unchecked.
834+
#[default]
823835
Unchecked,
824836
/// The check box or radio button is checked.
825837
Checked,

src/content.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,12 @@ impl LineJoinStyle {
222222
}
223223
}
224224
/// How the output device should aim to render colors.
225-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
225+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
226226
pub enum RenderingIntent {
227227
/// Only consider the light source, not the output's white point.
228228
AbsoluteColorimetric,
229229
/// Consider both the light source and the output's white point.
230+
#[default]
230231
RelativeColorimetric,
231232
/// Preserve saturation.
232233
Saturation,
@@ -502,9 +503,10 @@ impl Content {
502503
}
503504

504505
/// How to render text.
505-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
506+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
506507
pub enum TextRenderingMode {
507508
/// Just fill the text.
509+
#[default]
508510
Fill,
509511
/// Just stroke the text.
510512
Stroke,
@@ -1528,9 +1530,10 @@ impl ExtGraphicsState<'_> {
15281530
deref!('a, ExtGraphicsState<'a> => Dict<'a>, dict);
15291531

15301532
/// How to blend source and backdrop.
1531-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
1533+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
15321534
#[allow(missing_docs)]
15331535
pub enum BlendMode {
1536+
#[default]
15341537
Normal,
15351538
Multiply,
15361539
Screen,
@@ -1573,10 +1576,11 @@ impl BlendMode {
15731576
}
15741577

15751578
/// How to behave when overprinting for colorants with the value zero.
1576-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
1579+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
15771580
pub enum OverprintMode {
15781581
/// An overprint operation will always discard the underlying color, even if
15791582
/// one of the colorants is zero.
1583+
#[default]
15801584
OverrideAllColorants,
15811585
/// An overprint operation will only discard the underlying colorant
15821586
/// component (e.g. cyan in CMYK) if the new corresponding colorant is

src/files.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ deref!('a, EmbeddingParams<'a> => Dict<'a>, dict);
161161

162162
/// How an embedded file relates to the PDF document it is embedded in.
163163
/// PDF 1.7 with PDF/A-3, PDF 2.0+ (including PDF/A-4f).
164-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
164+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
165165
pub enum AssociationKind {
166166
/// The PDF document was created from this source file.
167167
Source,
@@ -178,6 +178,7 @@ pub enum AssociationKind {
178178
/// A machine-readable schema. PDF 2.0+.
179179
Schema,
180180
/// There is no clear relationship or it is not known.
181+
#[default]
181182
Unspecified,
182183
}
183184

src/font.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,10 @@ impl<'a> Cmap<'a> {
830830
deref!('a, Cmap<'a> => Stream<'a>, stream);
831831

832832
/// The writing mode of a character map.
833-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
833+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
834834
#[allow(missing_docs)]
835835
pub enum WMode {
836+
#[default]
836837
Horizontal,
837838
Vertical,
838839
}

src/forms.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,10 @@ impl Field<'_> {
339339
}
340340

341341
/// The quadding (justification) of a field containing variable text.
342-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
342+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
343343
pub enum Quadding {
344344
/// Left justify the text.
345+
#[default]
345346
Left = 0,
346347
/// Center justify the text.
347348
Center = 1,

src/functions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ deref!('a, SampledFunction<'a> => Stream<'a>, stream);
104104

105105
/// How to interpolate between the samples in a function of the
106106
/// sampled type.
107-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
107+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
108108
pub enum InterpolationOrder {
109109
/// Linear spline interpolation.
110+
#[default]
110111
Linear,
111112
/// Cubic spline interpolation.
112113
Cubic,

src/object.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,10 +1102,11 @@ impl DecodeParms<'_> {
11021102
deref!('a, DecodeParms<'a> => Dict<'a>, dict);
11031103

11041104
/// Which kind of predictor to use for a `FlateDecode` or `LzwDecode` stream.
1105-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
1105+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
11061106
#[allow(missing_docs)]
11071107
pub enum Predictor {
11081108
/// No prediction.
1109+
#[default]
11091110
None,
11101111
/// TIFF Predictor 2.
11111112
Tiff,

src/renditions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ deref!('a, MediaPermissions<'a> => Dict<'a>, dict);
173173

174174
/// The circumstances under which it is acceptable to write a temporary file in
175175
/// order to play a media clip.
176-
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
176+
#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
177177
pub enum TempFileType {
178178
/// Never allowed.
179+
#[default]
179180
Never,
180181
/// Allowed only if the document permissions allow content extraction.
181182
Extract,

0 commit comments

Comments
 (0)