lexical_parse_integer/
parse.rs
1#![doc(hidden)]
4
5use lexical_util::num::Integer;
7use lexical_util::result::Result;
8
9use crate::algorithm::{algorithm_complete, algorithm_partial};
10use crate::Options;
11
12pub trait ParseInteger: Integer {
14 #[cfg_attr(not(feature = "compact"), inline(always))]
16 fn parse_complete<const FORMAT: u128>(bytes: &[u8], options: &Options) -> Result<Self> {
17 algorithm_complete::<_, { FORMAT }>(bytes, options)
18 }
19
20 #[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
27macro_rules! parse_integer_impl {
28 ($($t:ty)*) => ($(
29 impl ParseInteger for $t {}
30 )*)
31}
32
33parse_integer_impl! { u8 u16 u32 u64 u128 usize }
34parse_integer_impl! { i8 i16 i32 i64 i128 isize }