Skip to main content

time/format_description/
modifier.rs

1//! Various modifiers for components.
2
3use core::num::NonZero;
4
5/// Generate the provided code if and only if `pub` is present.
6macro_rules! if_pub {
7    (pub $(#[$attr:meta])*; $($x:tt)*) => {
8        $(#[$attr])*
9        ///
10        /// This function exists since [`Default::default()`] cannot be used in a `const` context.
11        /// It may be removed once that becomes possible. As the [`Default`] trait is in the
12        /// prelude, removing this function in the future will not cause any resolution failures for
13        /// the overwhelming majority of users; only users who use `#![no_implicit_prelude]` will be
14        /// affected. As such it will not be considered a breaking change.
15        $($x)*
16    };
17    ($($_:tt)*) => {};
18}
19
20/// Implement `Default` for the given type. This also generates an inherent implementation of a
21/// `default` method that is `const fn`, permitting the default value to be used in const contexts.
22// Every modifier should use this macro rather than a derived `Default`.
23macro_rules! impl_const_default {
24    ($($(#[$doc:meta])* $(@$pub:ident)? $type:ty => $default:expr;)*) => {$(
25        impl $type {
26            if_pub! {
27                $($pub)?
28                $(#[$doc])*;
29                #[inline]
30                pub const fn default() -> Self {
31                    $default
32                }
33            }
34        }
35
36        $(#[$doc])*
37        impl Default for $type {
38            #[inline]
39            fn default() -> Self {
40                $default
41            }
42        }
43    )*};
44}
45
46// Keep this first so that it's shown at the top of documentation.
47impl_const_default! {
48    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
49    @pub Day => Self { padding: Padding::Zero };
50    /// Creates a modifier that indicates the value uses the
51    /// [`Numerical`](Self::Numerical) representation.
52    MonthRepr => Self::Numerical;
53    /// Creates an instance of this type that indicates the value uses the
54    /// [`Numerical`](MonthRepr::Numerical) representation, is [padded with zeroes](Padding::Zero),
55    /// and is case-sensitive when parsing.
56    @pub Month => Self {
57        padding: Padding::Zero,
58        repr: MonthRepr::Numerical,
59        case_sensitive: true,
60    };
61    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
62    @pub Ordinal => Self { padding: Padding::Zero };
63    /// Creates a modifier that indicates the value uses the [`Long`](Self::Long) representation.
64    WeekdayRepr => Self::Long;
65    /// Creates a modifier that indicates the value uses the [`Long`](WeekdayRepr::Long)
66    /// representation and is case-sensitive when parsing. If the representation is changed to a
67    /// numerical one, the instance defaults to one-based indexing.
68    @pub Weekday => Self {
69        repr: WeekdayRepr::Long,
70        one_indexed: true,
71        case_sensitive: true,
72    };
73    /// Creates a modifier that indicates that the value uses the [`Iso`](Self::Iso) representation.
74    WeekNumberRepr => Self::Iso;
75    /// Creates a modifier that indicates that the value is [padded with zeroes](Padding::Zero)
76            /// and uses the [`Iso`](WeekNumberRepr::Iso) representation.
77    @pub WeekNumber => Self {
78        padding: Padding::Zero,
79        repr: WeekNumberRepr::Iso,
80    };
81    /// Creates a modifier that indicates the value uses the [`Full`](Self::Full) representation.
82    YearRepr => Self::Full;
83    /// Creates a modifier that indicates the value uses the [`Extended`](Self::Extended) range.
84    YearRange => Self::Extended;
85    /// Creates a modifier that indicates the value uses the [`Full`](YearRepr::Full)
86    /// representation, is [padded with zeroes](Padding::Zero), uses the Gregorian calendar as its
87    /// base, and only includes the year's sign if necessary.
88    @pub Year => Self {
89        padding: Padding::Zero,
90        repr: YearRepr::Full,
91        range: YearRange::Extended,
92        iso_week_based: false,
93        sign_is_mandatory: false,
94    };
95    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero) and
96    /// has the 24-hour representation.
97    @pub Hour => Self {
98        padding: Padding::Zero,
99        is_12_hour_clock: false,
100    };
101    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
102    @pub Minute => Self { padding: Padding::Zero };
103    /// Creates a modifier that indicates the value uses the upper-case representation and is
104    /// case-sensitive when parsing.
105    @pub Period => Self {
106        is_uppercase: true,
107        case_sensitive: true,
108    };
109    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
110    @pub Second => Self { padding: Padding::Zero };
111    /// Creates a modifier that indicates the stringified value contains [one or more
112    /// digits](Self::OneOrMore).
113    SubsecondDigits => Self::OneOrMore;
114    /// Creates a modifier that indicates the stringified value contains [one or more
115    /// digits](SubsecondDigits::OneOrMore).
116    @pub Subsecond => Self { digits: SubsecondDigits::OneOrMore };
117    /// Creates a modifier that indicates the value only uses a sign for negative values and is
118    /// [padded with zeroes](Padding::Zero).
119    @pub OffsetHour => Self {
120        sign_is_mandatory: false,
121        padding: Padding::Zero,
122    };
123    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
124    @pub OffsetMinute => Self { padding: Padding::Zero };
125    /// Creates a modifier that indicates the value is [padded with zeroes](Padding::Zero).
126    @pub OffsetSecond => Self { padding: Padding::Zero };
127    /// Creates a modifier that indicates the value is [padded with zeroes](Self::Zero).
128    Padding => Self::Zero;
129    /// Creates a modifier that indicates the value represents the [number of seconds](Self::Second)
130    /// since the Unix epoch.
131    UnixTimestampPrecision => Self::Second;
132    /// Creates a modifier that indicates the value represents the [number of
133    /// seconds](UnixTimestampPrecision::Second) since the Unix epoch. The sign is not mandatory.
134    @pub UnixTimestamp => Self {
135        precision: UnixTimestampPrecision::Second,
136        sign_is_mandatory: false,
137    };
138    /// Indicate that any trailing characters after the end of input are prohibited and will cause
139    /// an error when used with `parse`.
140    TrailingInput => Self::Prohibit;
141    /// Creates a modifier used to represent the end of input, not allowing any trailing input (i.e.
142    /// the input must be fully consumed).
143    @pub End => Self { trailing_input: TrailingInput::Prohibit };
144}
145
146/// Day of the month.
147#[non_exhaustive]
148#[derive(Debug, Clone, Copy, PartialEq, Eq)]
149pub struct Day {
150    /// The padding to obtain the minimum width.
151    pub padding: Padding,
152}
153
154impl Day {
155    /// Set the padding type.
156    #[inline]
157    #[must_use = "this returns the result of the operation, without modifying the original"]
158    pub const fn with_padding(self, padding: Padding) -> Self {
159        Self { padding }
160    }
161}
162
163/// The representation of a month.
164#[non_exhaustive]
165#[derive(Debug, Clone, Copy, PartialEq, Eq)]
166pub enum MonthRepr {
167    /// The number of the month (January is 1, December is 12).
168    Numerical,
169    /// The long form of the month name (e.g. "January").
170    Long,
171    /// The short form of the month name (e.g. "Jan").
172    Short,
173}
174
175/// Month of the year.
176#[non_exhaustive]
177#[derive(Debug, Clone, Copy, PartialEq, Eq)]
178pub struct Month {
179    /// The padding to obtain the minimum width.
180    pub padding: Padding,
181    /// What form of representation should be used?
182    pub repr: MonthRepr,
183    /// Is the value case sensitive when parsing?
184    pub case_sensitive: bool,
185}
186
187impl Month {
188    /// Set the padding type.
189    #[inline]
190    #[must_use = "this returns the result of the operation, without modifying the original"]
191    pub const fn with_padding(self, padding: Padding) -> Self {
192        Self { padding, ..self }
193    }
194
195    /// Set the manner in which the month is represented.
196    #[inline]
197    #[must_use = "this returns the result of the operation, without modifying the original"]
198    pub const fn with_repr(self, repr: MonthRepr) -> Self {
199        Self { repr, ..self }
200    }
201
202    /// Set whether the value is case sensitive when parsing.
203    #[inline]
204    #[must_use = "this returns the result of the operation, without modifying the original"]
205    pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
206        Self {
207            case_sensitive,
208            ..self
209        }
210    }
211}
212
213/// Ordinal day of the year.
214#[non_exhaustive]
215#[derive(Debug, Clone, Copy, PartialEq, Eq)]
216pub struct Ordinal {
217    /// The padding to obtain the minimum width.
218    pub padding: Padding,
219}
220
221impl Ordinal {
222    /// Set the padding type.
223    #[inline]
224    #[must_use = "this returns the result of the operation, without modifying the original"]
225    pub const fn with_padding(self, padding: Padding) -> Self {
226        Self { padding }
227    }
228}
229
230/// The representation used for the day of the week.
231#[non_exhaustive]
232#[derive(Debug, Clone, Copy, PartialEq, Eq)]
233pub enum WeekdayRepr {
234    /// The short form of the weekday (e.g. "Mon").
235    Short,
236    /// The long form of the weekday (e.g. "Monday").
237    Long,
238    /// A numerical representation using Sunday as the first day of the week.
239    ///
240    /// Sunday is either 0 or 1, depending on the other modifier's value.
241    Sunday,
242    /// A numerical representation using Monday as the first day of the week.
243    ///
244    /// Monday is either 0 or 1, depending on the other modifier's value.
245    Monday,
246}
247
248/// Day of the week.
249#[non_exhaustive]
250#[derive(Debug, Clone, Copy, PartialEq, Eq)]
251pub struct Weekday {
252    /// What form of representation should be used?
253    pub repr: WeekdayRepr,
254    /// When using a numerical representation, should it be zero or one-indexed?
255    pub one_indexed: bool,
256    /// Is the value case sensitive when parsing?
257    pub case_sensitive: bool,
258}
259
260impl Weekday {
261    /// Set the manner in which the weekday is represented.
262    #[inline]
263    #[must_use = "this returns the result of the operation, without modifying the original"]
264    pub const fn with_repr(self, repr: WeekdayRepr) -> Self {
265        Self { repr, ..self }
266    }
267
268    /// Set whether the value is one-indexed when using a numerical representation.
269    #[inline]
270    #[must_use = "this returns the result of the operation, without modifying the original"]
271    pub const fn with_one_indexed(self, one_indexed: bool) -> Self {
272        Self {
273            one_indexed,
274            ..self
275        }
276    }
277
278    /// Set whether the value is case sensitive when parsing.
279    #[inline]
280    #[must_use = "this returns the result of the operation, without modifying the original"]
281    pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
282        Self {
283            case_sensitive,
284            ..self
285        }
286    }
287}
288
289/// The representation used for the week number.
290#[non_exhaustive]
291#[derive(Debug, Clone, Copy, PartialEq, Eq)]
292pub enum WeekNumberRepr {
293    /// Week 1 is the week that contains January 4.
294    Iso,
295    /// Week 1 begins on the first Sunday of the calendar year.
296    Sunday,
297    /// Week 1 begins on the first Monday of the calendar year.
298    Monday,
299}
300
301/// Week within the year.
302#[non_exhaustive]
303#[derive(Debug, Clone, Copy, PartialEq, Eq)]
304pub struct WeekNumber {
305    /// The padding to obtain the minimum width.
306    pub padding: Padding,
307    /// What kind of representation should be used?
308    pub repr: WeekNumberRepr,
309}
310
311impl WeekNumber {
312    /// Set the padding type.
313    #[inline]
314    #[must_use = "this returns the result of the operation, without modifying the original"]
315    pub const fn with_padding(self, padding: Padding) -> Self {
316        Self { padding, ..self }
317    }
318
319    /// Set the manner in which the week number is represented.
320    #[inline]
321    #[must_use = "this returns the result of the operation, without modifying the original"]
322    pub const fn with_repr(self, repr: WeekNumberRepr) -> Self {
323        Self { repr, ..self }
324    }
325}
326
327/// The representation used for a year value.
328#[non_exhaustive]
329#[derive(Debug, Clone, Copy, PartialEq, Eq)]
330pub enum YearRepr {
331    /// The full value of the year.
332    Full,
333    /// All digits except the last two. Includes the sign, if any.
334    Century,
335    /// Only the last two digits of the year.
336    LastTwo,
337}
338
339/// The range of years that are supported.
340///
341/// This modifier has no effect when the year repr is [`LastTwo`](YearRepr::LastTwo).
342#[non_exhaustive]
343#[derive(Debug, Clone, Copy, PartialEq, Eq)]
344pub enum YearRange {
345    /// Years between -9999 and 9999 are supported.
346    Standard,
347    /// Years between -999_999 and 999_999 are supported, with the sign being required if the year
348    /// contains more than four digits.
349    ///
350    /// If the `large-dates` feature is not enabled, this variant is equivalent to `Standard`.
351    Extended,
352}
353
354/// Year of the date.
355#[non_exhaustive]
356#[derive(Debug, Clone, Copy, PartialEq, Eq)]
357pub struct Year {
358    /// The padding to obtain the minimum width.
359    pub padding: Padding,
360    /// What kind of representation should be used?
361    pub repr: YearRepr,
362    /// What range of years is supported?
363    pub range: YearRange,
364    /// Whether the value is based on the ISO week number or the Gregorian calendar.
365    pub iso_week_based: bool,
366    /// Whether the `+` sign is present when a positive year contains fewer than five digits.
367    pub sign_is_mandatory: bool,
368}
369
370impl Year {
371    /// Set the padding type.
372    #[inline]
373    #[must_use = "this returns the result of the operation, without modifying the original"]
374    pub const fn with_padding(self, padding: Padding) -> Self {
375        Self { padding, ..self }
376    }
377
378    /// Set the manner in which the year is represented.
379    #[inline]
380    #[must_use = "this returns the result of the operation, without modifying the original"]
381    pub const fn with_repr(self, repr: YearRepr) -> Self {
382        Self { repr, ..self }
383    }
384
385    /// Set the range of years that are supported.
386    #[inline]
387    #[must_use = "this returns the result of the operation, without modifying the original"]
388    pub const fn with_range(self, range: YearRange) -> Self {
389        Self { range, ..self }
390    }
391
392    /// Set whether the year is based on the ISO week number.
393    #[inline]
394    #[must_use = "this returns the result of the operation, without modifying the original"]
395    pub const fn with_iso_week_based(self, iso_week_based: bool) -> Self {
396        Self {
397            iso_week_based,
398            ..self
399        }
400    }
401
402    /// Set whether the `+` sign is mandatory for positive years with fewer than five digits.
403    #[inline]
404    #[must_use = "this returns the result of the operation, without modifying the original"]
405    pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
406        Self {
407            sign_is_mandatory,
408            ..self
409        }
410    }
411}
412
413/// Hour of the day.
414#[non_exhaustive]
415#[derive(Debug, Clone, Copy, PartialEq, Eq)]
416pub struct Hour {
417    /// The padding to obtain the minimum width.
418    pub padding: Padding,
419    /// Is the hour displayed using a 12 or 24-hour clock?
420    pub is_12_hour_clock: bool,
421}
422
423impl Hour {
424    /// Set the padding type.
425    #[inline]
426    #[must_use = "this returns the result of the operation, without modifying the original"]
427    pub const fn with_padding(self, padding: Padding) -> Self {
428        Self { padding, ..self }
429    }
430
431    /// Set whether the hour uses a 12-hour clock.
432    #[inline]
433    #[must_use = "this returns the result of the operation, without modifying the original"]
434    pub const fn with_is_12_hour_clock(self, is_12_hour_clock: bool) -> Self {
435        Self {
436            is_12_hour_clock,
437            ..self
438        }
439    }
440}
441
442/// Minute within the hour.
443#[non_exhaustive]
444#[derive(Debug, Clone, Copy, PartialEq, Eq)]
445pub struct Minute {
446    /// The padding to obtain the minimum width.
447    pub padding: Padding,
448}
449
450impl Minute {
451    /// Set the padding type.
452    #[inline]
453    #[must_use = "this returns the result of the operation, without modifying the original"]
454    pub const fn with_padding(self, padding: Padding) -> Self {
455        Self { padding }
456    }
457}
458
459/// AM/PM part of the time.
460#[non_exhaustive]
461#[derive(Debug, Clone, Copy, PartialEq, Eq)]
462pub struct Period {
463    /// Is the period uppercase or lowercase?
464    pub is_uppercase: bool,
465    /// Is the value case sensitive when parsing?
466    ///
467    /// Note that when `false`, the `is_uppercase` field has no effect on parsing behavior.
468    pub case_sensitive: bool,
469}
470
471impl Period {
472    /// Set whether the period is uppercase.
473    #[inline]
474    #[must_use = "this returns the result of the operation, without modifying the original"]
475    pub const fn with_is_uppercase(self, is_uppercase: bool) -> Self {
476        Self {
477            is_uppercase,
478            ..self
479        }
480    }
481
482    /// Set whether the value is case sensitive when parsing.
483    #[inline]
484    #[must_use = "this returns the result of the operation, without modifying the original"]
485    pub const fn with_case_sensitive(self, case_sensitive: bool) -> Self {
486        Self {
487            case_sensitive,
488            ..self
489        }
490    }
491}
492
493/// Second within the minute.
494#[non_exhaustive]
495#[derive(Debug, Clone, Copy, PartialEq, Eq)]
496pub struct Second {
497    /// The padding to obtain the minimum width.
498    pub padding: Padding,
499}
500
501impl Second {
502    /// Set the padding type.
503    #[inline]
504    #[must_use = "this returns the result of the operation, without modifying the original"]
505    pub const fn with_padding(self, padding: Padding) -> Self {
506        Self { padding }
507    }
508}
509
510/// The number of digits present in a subsecond representation.
511#[non_exhaustive]
512#[derive(Debug, Clone, Copy, PartialEq, Eq)]
513pub enum SubsecondDigits {
514    /// Exactly one digit.
515    One,
516    /// Exactly two digits.
517    Two,
518    /// Exactly three digits.
519    Three,
520    /// Exactly four digits.
521    Four,
522    /// Exactly five digits.
523    Five,
524    /// Exactly six digits.
525    Six,
526    /// Exactly seven digits.
527    Seven,
528    /// Exactly eight digits.
529    Eight,
530    /// Exactly nine digits.
531    Nine,
532    /// Any number of digits (up to nine) that is at least one. When formatting, the minimum digits
533    /// necessary will be used.
534    OneOrMore,
535}
536
537/// Subsecond within the second.
538#[non_exhaustive]
539#[derive(Debug, Clone, Copy, PartialEq, Eq)]
540pub struct Subsecond {
541    /// How many digits are present in the component?
542    pub digits: SubsecondDigits,
543}
544
545impl Subsecond {
546    /// Set the number of digits present in the subsecond representation.
547    #[inline]
548    #[must_use = "this returns the result of the operation, without modifying the original"]
549    pub const fn with_digits(self, digits: SubsecondDigits) -> Self {
550        Self { digits }
551    }
552}
553
554/// Hour of the UTC offset.
555#[non_exhaustive]
556#[derive(Debug, Clone, Copy, PartialEq, Eq)]
557pub struct OffsetHour {
558    /// Whether the `+` sign is present on positive values.
559    pub sign_is_mandatory: bool,
560    /// The padding to obtain the minimum width.
561    pub padding: Padding,
562}
563
564impl OffsetHour {
565    /// Set whether the `+` sign is mandatory for positive values.
566    #[inline]
567    #[must_use = "this returns the result of the operation, without modifying the original"]
568    pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
569        Self {
570            sign_is_mandatory,
571            ..self
572        }
573    }
574
575    /// Set the padding type.
576    #[inline]
577    #[must_use = "this returns the result of the operation, without modifying the original"]
578    pub const fn with_padding(self, padding: Padding) -> Self {
579        Self { padding, ..self }
580    }
581}
582
583/// Minute within the hour of the UTC offset.
584#[non_exhaustive]
585#[derive(Debug, Clone, Copy, PartialEq, Eq)]
586pub struct OffsetMinute {
587    /// The padding to obtain the minimum width.
588    pub padding: Padding,
589}
590
591impl OffsetMinute {
592    /// Set the padding type.
593    #[inline]
594    #[must_use = "this returns the result of the operation, without modifying the original"]
595    pub const fn with_padding(self, padding: Padding) -> Self {
596        Self { padding }
597    }
598}
599
600/// Second within the minute of the UTC offset.
601#[non_exhaustive]
602#[derive(Debug, Clone, Copy, PartialEq, Eq)]
603pub struct OffsetSecond {
604    /// The padding to obtain the minimum width.
605    pub padding: Padding,
606}
607
608impl OffsetSecond {
609    /// Set the padding type.
610    #[inline]
611    #[must_use = "this returns the result of the operation, without modifying the original"]
612    pub const fn with_padding(self, padding: Padding) -> Self {
613        Self { padding }
614    }
615}
616
617/// Type of padding to ensure a minimum width.
618#[non_exhaustive]
619#[derive(Debug, Clone, Copy, PartialEq, Eq)]
620pub enum Padding {
621    /// A space character (` `) should be used as padding.
622    Space,
623    /// A zero character (`0`) should be used as padding.
624    Zero,
625    /// There is no padding. This can result in a width below the otherwise minimum number of
626    /// characters.
627    None,
628}
629
630/// Ignore some number of bytes.
631///
632/// This has no effect when formatting.
633#[non_exhaustive]
634#[derive(Debug, Clone, Copy, PartialEq, Eq)]
635pub struct Ignore {
636    /// The number of bytes to ignore.
637    pub count: NonZero<u16>,
638}
639
640// Needed as `Default` is deliberately not implemented for `Ignore`. The number of bytes to ignore
641// must be explicitly provided.
642impl Ignore {
643    /// Create an instance of `Ignore` with the provided number of bytes to ignore.
644    #[inline]
645    pub const fn count(count: NonZero<u16>) -> Self {
646        Self { count }
647    }
648
649    /// Set the number of bytes to ignore.
650    #[inline]
651    #[must_use = "this returns the result of the operation, without modifying the original"]
652    pub const fn with_count(self, count: NonZero<u16>) -> Self {
653        Self { count }
654    }
655}
656
657/// The precision of a Unix timestamp.
658#[non_exhaustive]
659#[derive(Debug, Clone, Copy, PartialEq, Eq)]
660pub enum UnixTimestampPrecision {
661    /// Seconds since the Unix epoch.
662    Second,
663    /// Milliseconds since the Unix epoch.
664    Millisecond,
665    /// Microseconds since the Unix epoch.
666    Microsecond,
667    /// Nanoseconds since the Unix epoch.
668    Nanosecond,
669}
670
671/// A Unix timestamp.
672#[non_exhaustive]
673#[derive(Debug, Clone, Copy, PartialEq, Eq)]
674pub struct UnixTimestamp {
675    /// The precision of the timestamp.
676    pub precision: UnixTimestampPrecision,
677    /// Whether the `+` sign must be present for a non-negative timestamp.
678    pub sign_is_mandatory: bool,
679}
680
681impl UnixTimestamp {
682    /// Set the precision of the timestamp.
683    #[inline]
684    #[must_use = "this returns the result of the operation, without modifying the original"]
685    pub const fn with_precision(self, precision: UnixTimestampPrecision) -> Self {
686        Self { precision, ..self }
687    }
688
689    /// Set whether the `+` sign is mandatory for non-negative timestamps.
690    #[inline]
691    #[must_use = "this returns the result of the operation, without modifying the original"]
692    pub const fn with_sign_is_mandatory(self, sign_is_mandatory: bool) -> Self {
693        Self {
694            sign_is_mandatory,
695            ..self
696        }
697    }
698}
699
700/// Whether trailing input after the declared end is permitted.
701#[derive(Debug, Clone, Copy, PartialEq, Eq)]
702pub enum TrailingInput {
703    /// Trailing input is not permitted and will cause an error.
704    Prohibit,
705    /// Trailing input is permitted but discarded.
706    Discard,
707}
708
709/// The end of input.
710#[non_exhaustive]
711#[derive(Debug, Clone, Copy, PartialEq, Eq)]
712pub struct End {
713    /// How to handle any input after this component.
714    pub(crate) trailing_input: TrailingInput,
715}
716
717impl End {
718    /// Set how to handle any input after this component.
719    #[inline]
720    #[must_use = "this returns the result of the operation, without modifying the original"]
721    pub const fn with_trailing_input(self, trailing_input: TrailingInput) -> Self {
722        Self {
723            trailing_input,
724            ..self
725        }
726    }
727}