/rust/registry/src/index.crates.io-1949cf8c6b5b557f/time-0.3.44/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.71k | pub(crate) fn map<U>(self, f: impl FnOnce(T) -> U) -> ParsedItem<'a, U> { |
21 | 1.71k | ParsedItem(self.0, f(self.1)) |
22 | 1.71k | } Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<core::option::Option<u8>, core::option::Option<u8>::Some> Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<i8, <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>>::map::<i8, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_offset_date_time::{closure#3}::{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::<i8, time::parsing::component::parse_offset_minute::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<i8, time::parsing::component::parse_offset_second::{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::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#7}> <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.71k | pub(crate) fn map<U>(self, f: impl FnOnce(T) -> U) -> ParsedItem<'a, U> { | 21 | 1.71k | ParsedItem(self.0, f(self.1)) | 22 | 1.71k | } |
Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<(i32, bool), time::parsing::component::parse_year::{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#1}> 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#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<u32, <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::<u32, time::parsing::component::parse_subsecond::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<u32, time::parsing::component::parse_subsecond::{closure#2}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<u32, time::parsing::component::parse_subsecond::{closure#3}> 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<u32>>::map::<u32, time::parsing::component::parse_subsecond::{closure#1}> Unexecuted instantiation: <time::parsing::ParsedItem<u128>>::map::<u128, time::parsing::component::parse_unix_timestamp::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u128>>::map::<u128, time::parsing::component::parse_unix_timestamp::{closure#2}> Unexecuted instantiation: <time::parsing::ParsedItem<u128>>::map::<u128, time::parsing::component::parse_unix_timestamp::{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 | 175k | pub(crate) fn flat_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<ParsedItem<'a, U>> { |
27 | 175k | Some(ParsedItem(self.0, f(self.1)?)) |
28 | 175k | } Unexecuted instantiation: <time::parsing::ParsedItem<core::num::nonzero::NonZero<u8>>>::flat_map::<time::month::Month, <time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#1}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<core::num::nonzero::NonZero<u8>>>::flat_map::<time::month::Month, time::parsing::component::parse_month::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<core::num::nonzero::NonZero<u8>, time::parsing::combinator::n_to_m_digits<1, 2, core::num::nonzero::NonZero<u8>>::{closure#0}> <time::parsing::ParsedItem<&[u8]>>::flat_map::<core::num::nonzero::NonZero<u8>, time::parsing::combinator::n_to_m_digits<2, 2, core::num::nonzero::NonZero<u8>>::{closure#0}> Line | Count | Source | 26 | 22.5k | pub(crate) fn flat_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<ParsedItem<'a, U>> { | 27 | 22.5k | Some(ParsedItem(self.0, f(self.1)?)) | 28 | 22.5k | } |
Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<core::num::nonzero::NonZero<u8>, time::parsing::combinator::n_to_m_digits_padded<2, 2, core::num::nonzero::NonZero<u8>>::{closure#0}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<core::num::nonzero::NonZero<u16>, time::parsing::combinator::n_to_m_digits<1, 3, core::num::nonzero::NonZero<u16>>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<core::num::nonzero::NonZero<u16>, time::parsing::combinator::n_to_m_digits<3, 3, core::num::nonzero::NonZero<u16>>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<core::num::nonzero::NonZero<u16>, time::parsing::combinator::n_to_m_digits_padded<3, 3, core::num::nonzero::NonZero<u16>>::{closure#0}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u8, time::parsing::combinator::n_to_m_digits<1, 2, u8>::{closure#0}> <time::parsing::ParsedItem<&[u8]>>::flat_map::<u8, time::parsing::combinator::n_to_m_digits<2, 2, u8>::{closure#0}> Line | Count | Source | 26 | 130k | pub(crate) fn flat_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<ParsedItem<'a, U>> { | 27 | 130k | Some(ParsedItem(self.0, f(self.1)?)) | 28 | 130k | } |
Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u8, time::parsing::combinator::n_to_m_digits_padded<2, 2, u8>::{closure#0}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<1, 1, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<1, 2, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<1, 4, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<2, 2, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<3, 3, u32>::{closure#0}> <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<4, 4, u32>::{closure#0}> Line | Count | Source | 26 | 22.5k | pub(crate) fn flat_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<ParsedItem<'a, U>> { | 27 | 22.5k | Some(ParsedItem(self.0, f(self.1)?)) | 28 | 22.5k | } |
Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<5, 5, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<6, 6, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<7, 7, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<8, 8, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<9, 9, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits_padded<1, 2, u32>::{closure#0}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits_padded<2, 2, u32>::{closure#0}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits_padded<4, 4, u32>::{closure#0}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u128, time::parsing::combinator::n_to_m_digits<1, 17, u128>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u128, time::parsing::combinator::n_to_m_digits<1, 20, u128>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u128, time::parsing::combinator::n_to_m_digits<1, 23, u128>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u128, time::parsing::combinator::n_to_m_digits<1, 14, u128>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::flat_map::<u32, <time::format_description::well_known::rfc2822::Rfc2822 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#3}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::flat_map::<u32, <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<core::num::nonzero::NonZero<u8>>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#0}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<core::num::nonzero::NonZero<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<core::num::nonzero::NonZero<u8>>>::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<core::num::nonzero::NonZero<u16>>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#2}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<time::parsing::component::Period>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#7}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<time::month::Month>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#1}::{closure#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#2}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<time::weekday::Weekday>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{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, bool)>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#10}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<i8>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#11}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<i8>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#12}::{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#11}::{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#10}> Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#6}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{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#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#12}::{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<i32>>::consume_value::<<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>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#9}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::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<u32>>::consume_value::<<time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#0}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<i128>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#13}::{closure#0}> |
37 | | |
38 | | /// Filter the value with the provided function. If the function returns `false`, the value |
39 | | /// is discarded and `None` is returned. Otherwise, the value is preserved and `Some(self)` is |
40 | | /// returned. |
41 | | #[inline] |
42 | 20.2k | pub(crate) fn filter(self, f: impl FnOnce(&T) -> bool) -> Option<Self> { |
43 | 20.2k | f(&self.1).then_some(self) |
44 | 20.2k | } 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#1}::{closure#0}> Line | Count | Source | 42 | 20.2k | pub(crate) fn filter(self, f: impl FnOnce(&T) -> bool) -> Option<Self> { | 43 | 20.2k | f(&self.1).then_some(self) | 44 | 20.2k | } |
|
45 | | } |
46 | | |
47 | | impl<'a> ParsedItem<'a, ()> { |
48 | | /// Discard the unit value, returning the remaining input. |
49 | | #[must_use = "this returns the remaining input"] |
50 | | #[inline] |
51 | 110k | pub(crate) const fn into_inner(self) -> &'a [u8] { |
52 | 110k | self.0 |
53 | 110k | } |
54 | | } |
55 | | |
56 | | impl<'a> ParsedItem<'a, Option<()>> { |
57 | | /// Discard the potential unit value, returning the remaining input. |
58 | | #[must_use = "this returns the remaining input"] |
59 | | #[inline] |
60 | 0 | pub(crate) const fn into_inner(self) -> &'a [u8] { |
61 | 0 | self.0 |
62 | 0 | } |
63 | | } |