/rust/registry/src/index.crates.io-1949cf8c6b5b557f/time-0.3.51/src/parsing/mod.rs
Line | Count | Source |
1 | | //! Parsing for various types. |
2 | | |
3 | | pub(crate) mod combinator; |
4 | | pub(crate) mod component; |
5 | | mod iso8601; |
6 | | pub(crate) mod parsable; |
7 | | mod parsed; |
8 | | pub(crate) mod shim; |
9 | | |
10 | | pub use self::parsable::Parsable; |
11 | | pub use self::parsed::Parsed; |
12 | | |
13 | | /// An item that has been parsed. Represented as a `(remaining, value)` pair. |
14 | | #[derive(Debug)] |
15 | | pub(crate) struct ParsedItem<'a, T>(pub(crate) &'a [u8], pub(crate) T); |
16 | | |
17 | | impl<'a, T> ParsedItem<'a, T> { |
18 | | /// Map the value to a new value, preserving the remaining input. |
19 | | #[inline] |
20 | 1.47k | pub(crate) fn map<U>(self, f: impl FnOnce(T) -> U) -> ParsedItem<'a, U> { |
21 | 1.47k | ParsedItem(self.0, f(self.1)) |
22 | 1.47k | } Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<i8, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#10}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<i8, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_offset_date_time::{closure#2}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<i8, <time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#8}::{closure#1}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<i8, <time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#9}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<u32, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#5}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<u32, time::parsing::component::parse_subsecond::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<u32, time::parsing::component::parse_subsecond::{closure#8}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<u32, time::parsing::component::parse_subsecond::{closure#1}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<u32, <time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#0}><time::parsing::ParsedItem<u8>>::map::<u32, <time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_offset_date_time::{closure#0}>Line | Count | Source | 20 | 1.47k | pub(crate) fn map<U>(self, f: impl FnOnce(T) -> U) -> ParsedItem<'a, U> { | 21 | 1.47k | ParsedItem(self.0, f(self.1)) | 22 | 1.47k | } |
Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<u16, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_offset_date_time::{closure#1}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<i32, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#5}::{closure#2}>Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<u32, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#5}::{closure#1}>Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<u32, time::parsing::component::parse_subsecond::{closure#4}>Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<u32, time::parsing::component::parse_subsecond::{closure#5}>Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<u32, time::parsing::component::parse_subsecond::{closure#6}>Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<u32, time::parsing::component::parse_subsecond::{closure#7}>Unexecuted instantiation: <time::parsing::ParsedItem<u16>>::map::<u32, time::parsing::component::parse_subsecond::{closure#2}>Unexecuted instantiation: <time::parsing::ParsedItem<u16>>::map::<u32, time::parsing::component::parse_subsecond::{closure#3}>Unexecuted instantiation: <time::parsing::ParsedItem<u16>>::map::<u16, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_offset_date_time::{closure#1}::{closure#1}>Unexecuted instantiation: <time::parsing::ParsedItem<()>>::map::<core::option::Option<()>, core::option::Option<()>::Some> |
23 | | |
24 | | /// Map the value to a new, optional value, preserving the remaining input. |
25 | | #[inline] |
26 | 12.4k | pub(crate) fn flat_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<ParsedItem<'a, U>> { |
27 | 12.4k | Some(ParsedItem(self.0, f(self.1)?)) |
28 | 12.4k | } <time::parsing::ParsedItem<u8>>::flat_map::<core::num::nonzero::NonZero<u8>, <core::num::nonzero::NonZero<u8>>::new> Line | Count | Source | 26 | 12.4k | pub(crate) fn flat_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<ParsedItem<'a, U>> { | 27 | 12.4k | Some(ParsedItem(self.0, f(self.1)?)) | 28 | 12.4k | } |
Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::flat_map::<time::month::Month, <time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#2}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u16>>::flat_map::<u16, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#3}>Unexecuted instantiation: <time::parsing::ParsedItem<u16>>::flat_map::<u16, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_offset_date_time::{closure#0}> |
29 | | |
30 | | /// Consume the stored value with the provided function. The remaining input is returned. |
31 | | #[must_use = "this returns the remaining input"] |
32 | | #[inline] |
33 | 0 | pub(crate) fn consume_value(self, f: impl FnOnce(T) -> Option<()>) -> Option<&'a [u8]> { |
34 | 0 | f(self.1)?; |
35 | 0 | Some(self.0) |
36 | 0 | } Unexecuted instantiation: <time::parsing::ParsedItem<time::month::Month>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#2}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<time::month::Month>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#3}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<time::weekday::Weekday>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<i8>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#10}::{closure#1}>Unexecuted instantiation: <time::parsing::ParsedItem<i8>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#8}::{closure#2}>Unexecuted instantiation: <time::parsing::ParsedItem<i8>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#9}::{closure#1}>Unexecuted instantiation: <time::parsing::ParsedItem<i8>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#9}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#6}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#7}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#8}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#11}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#1}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#4}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#5}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#6}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#7}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<i32>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#5}::{closure#3}>Unexecuted instantiation: <time::parsing::ParsedItem<u16>>::consume_value::<<time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#4}::{closure#0}>Unexecuted instantiation: <time::parsing::ParsedItem<u16>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#1}::{closure#0}> |
37 | | |
38 | | /// Discard the stored value, returning the remaining input. |
39 | | #[must_use = "this returns the remaining input"] |
40 | | #[inline] |
41 | 0 | pub(crate) fn discard_value(self) -> &'a [u8] { |
42 | 0 | self.0 |
43 | 0 | } |
44 | | |
45 | | /// Filter the value with the provided function. If the function returns `false`, the value |
46 | | /// is discarded and `None` is returned. Otherwise, the value is preserved and `Some(self)` is |
47 | | /// returned. |
48 | | #[inline] |
49 | 9.03k | pub(crate) fn filter(self, f: impl FnOnce(&T) -> bool) -> Option<Self> { |
50 | 9.03k | f(&self.1).then_some(self) |
51 | 9.03k | } Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::filter::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#8}::{closure#0}><time::parsing::ParsedItem<u8>>::filter::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_offset_date_time::{closure#2}::{closure#0}>Line | Count | Source | 49 | 9.03k | pub(crate) fn filter(self, f: impl FnOnce(&T) -> bool) -> Option<Self> { | 50 | 9.03k | f(&self.1).then_some(self) | 51 | 9.03k | } |
|
52 | | } |
53 | | |
54 | | impl<'a> ParsedItem<'a, ()> { |
55 | | /// Discard the unit value, returning the remaining input. |
56 | | #[must_use = "this returns the remaining input"] |
57 | | #[inline] |
58 | 58.4k | pub(crate) const fn into_inner(self) -> &'a [u8] { |
59 | 58.4k | self.0 |
60 | 58.4k | } |
61 | | } |
62 | | |
63 | | impl<'a> ParsedItem<'a, Option<()>> { |
64 | | /// Discard the potential unit value, returning the remaining input. |
65 | | #[must_use = "this returns the remaining input"] |
66 | | #[inline] |
67 | 0 | pub(crate) const fn into_inner(self) -> &'a [u8] { |
68 | 0 | self.0 |
69 | 0 | } |
70 | | } |