/rust/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.41/src/parsing/mod.rs
Line | Count | Source (jump to first uncovered line) |
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 | 0 | pub(crate) fn map<U>(self, f: impl FnOnce(T) -> U) -> ParsedItem<'a, U> { |
20 | 0 | ParsedItem(self.0, f(self.1)) |
21 | 0 | } Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<core::option::Option<u8>, core::option::Option<u8>::Some> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<(i32, bool), time::parsing::component::parse_year::{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#1}> 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<u8>>::map::<u32, time::parsing::component::parse_subsecond::{closure#8}> 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<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#1}> Unexecuted instantiation: <time::parsing::ParsedItem<u128>>::map::<u128, time::parsing::component::parse_unix_timestamp::{closure#2}> 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}> 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::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::<u32, <time::format_description::well_known::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_offset_date_time::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<i32, time::parsing::combinator::rfc::iso8601::year::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::map::<i32, time::parsing::combinator::rfc::iso8601::year::{closure#1}> Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::map::<f64, time::parsing::combinator::rfc::iso8601::float::{closure#0}> |
22 | | |
23 | | /// Map the value to a new, optional value, preserving the remaining input. |
24 | 0 | pub(crate) fn flat_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<ParsedItem<'a, U>> { |
25 | 0 | Some(ParsedItem(self.0, f(self.1)?)) |
26 | 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::<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::<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_padded<2, 2, u32>::{closure#0}::{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::<u32, time::parsing::combinator::n_to_m_digits_padded<4, 4, u32>::{closure#0}::{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<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<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<1, 1, u32>::{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::<core::num::nonzero::NonZero<u8>, time::parsing::combinator::n_to_m_digits<1, 2, core::num::nonzero::NonZero<u8>>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u8, time::parsing::combinator::n_to_m_digits<1, 2, u8>::{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::<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::<u32, time::parsing::combinator::n_to_m_digits<1, 4, u32>::{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<&[u8]>>::flat_map::<core::num::nonzero::NonZero<u8>, time::parsing::combinator::n_to_m_digits<2, 2, core::num::nonzero::NonZero<u8>>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u8, time::parsing::combinator::n_to_m_digits<2, 2, u8>::{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::<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::<u32, time::parsing::combinator::n_to_m_digits<3, 3, u32>::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<&[u8]>>::flat_map::<u32, time::parsing::combinator::n_to_m_digits<4, 4, u32>::{closure#0}> 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}> |
27 | | |
28 | | /// Consume the stored value with the provided function. The remaining input is returned. |
29 | | #[must_use = "this returns the remaining input"] |
30 | 0 | pub(crate) fn consume_value(self, f: impl FnOnce(T) -> Option<()>) -> Option<&'a [u8]> { |
31 | 0 | f(self.1)?; |
32 | 0 | Some(self.0) |
33 | 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<time::month::Month>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#1}::{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::weekday::Weekday>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#3}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u8>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#6}::{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<u8>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#8}::{closure#0}> Unexecuted instantiation: <time::parsing::ParsedItem<u32>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#9}::{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<i128>>::consume_value::<<time::parsing::parsed::Parsed>::parse_component::{closure#13}::{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<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<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<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<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::rfc3339::Rfc3339 as time::parsing::parsable::sealed::Sealed>::parse_into::{closure#8}::{closure#2}> |
34 | | |
35 | | /// Filter the value with the provided function. If the function returns `false`, the value |
36 | | /// is discarded and `None` is returned. Otherwise, the value is preserved and `Some(self)` is |
37 | | /// returned. |
38 | 0 | pub(crate) fn filter(self, f: impl FnOnce(&T) -> bool) -> Option<Self> { |
39 | 0 | f(&self.1).then_some(self) |
40 | 0 | } 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}> Unexecuted instantiation: <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}> |
41 | | } |
42 | | |
43 | | impl<'a> ParsedItem<'a, ()> { |
44 | | /// Discard the unit value, returning the remaining input. |
45 | | #[must_use = "this returns the remaining input"] |
46 | 0 | pub(crate) const fn into_inner(self) -> &'a [u8] { |
47 | 0 | self.0 |
48 | 0 | } |
49 | | } |
50 | | |
51 | | impl<'a> ParsedItem<'a, Option<()>> { |
52 | | /// Discard the potential unit value, returning the remaining input. |
53 | | #[must_use = "this returns the remaining input"] |
54 | | pub(crate) const fn into_inner(self) -> &'a [u8] { |
55 | | self.0 |
56 | | } |
57 | | } |