/rust/registry/src/index.crates.io-1949cf8c6b5b557f/lexical-parse-integer-1.0.6/src/parse.rs
Line | Count | Source |
1 | | //! Shared trait and methods for parsing integers. |
2 | | |
3 | | #![doc(hidden)] |
4 | | |
5 | | // Select the correct back-end. |
6 | | use lexical_util::num::Integer; |
7 | | use lexical_util::result::Result; |
8 | | |
9 | | use crate::algorithm::{algorithm_complete, algorithm_partial}; |
10 | | use crate::Options; |
11 | | |
12 | | /// Parse integer trait, implemented in terms of the optimized back-end. |
13 | | pub trait ParseInteger: Integer { |
14 | | /// Forward complete parser parameters to the backend. |
15 | | #[cfg_attr(not(feature = "compact"), inline(always))] |
16 | 15.9k | fn parse_complete<const FORMAT: u128>(bytes: &[u8], options: &Options) -> Result<Self> { |
17 | 15.9k | algorithm_complete::<_, { FORMAT }>(bytes, options) |
18 | 15.9k | } Unexecuted instantiation: <u8 as lexical_parse_integer::parse::ParseInteger>::parse_complete::<0xa0000000000000000000000000c> <i32 as lexical_parse_integer::parse::ParseInteger>::parse_complete::<0xa0000000000000000000000000c> Line | Count | Source | 16 | 15.9k | fn parse_complete<const FORMAT: u128>(bytes: &[u8], options: &Options) -> Result<Self> { | 17 | 15.9k | algorithm_complete::<_, { FORMAT }>(bytes, options) | 18 | 15.9k | } |
Unexecuted instantiation: <i64 as lexical_parse_integer::parse::ParseInteger>::parse_complete::<0xa0000000000000000000000000c> Unexecuted instantiation: <u64 as lexical_parse_integer::parse::ParseInteger>::parse_complete::<0xa0000000000000000000000000c> |
19 | | |
20 | | /// Forward partial parser parameters to the backend. |
21 | | #[cfg_attr(not(feature = "compact"), inline(always))] |
22 | | fn parse_partial<const FORMAT: u128>(bytes: &[u8], options: &Options) -> Result<(Self, usize)> { |
23 | | algorithm_partial::<_, { FORMAT }>(bytes, options) |
24 | | } |
25 | | } |
26 | | |
27 | | macro_rules! parse_integer_impl { |
28 | | ($($t:ty)*) => ($( |
29 | | impl ParseInteger for $t {} |
30 | | )*) |
31 | | } |
32 | | |
33 | | parse_integer_impl! { u8 u16 u32 u64 u128 usize } |
34 | | parse_integer_impl! { i8 i16 i32 i64 i128 isize } |