pub struct JsonNum { /* private fields */ }Expand description
A JSON number span — (start, end) into the original input.
Numbers are not eagerly decoded — JSON numbers are arbitrary-precision
decimal and there is no Rust primitive that losslessly fits all of them.
Decoding is the consumer’s choice via as_i64, as_u64, as_f64.
Implementations§
Source§impl JsonNum
impl JsonNum
pub const fn start(&self) -> u32
pub const fn end(&self) -> u32
Sourcepub fn raw_bytes<'input>(&self, input: &'input [u8]) -> Option<&'input [u8]>
pub fn raw_bytes<'input>(&self, input: &'input [u8]) -> Option<&'input [u8]>
Raw bytes of the number literal, taken from the original input.
Sourcepub fn as_str<'input>(&self, input: &'input [u8]) -> &'input str
pub fn as_str<'input>(&self, input: &'input [u8]) -> &'input str
The raw number text. Always ASCII (lexer guarantees this).
Sourcepub fn is_float(&self, input: &[u8]) -> bool
pub fn is_float(&self, input: &[u8]) -> bool
True if the literal contains ., e, or E — i.e. is not an integer.
pub fn as_i64(&self, input: &[u8]) -> Result<i64, ErrorKind>
pub fn as_u64(&self, input: &[u8]) -> Result<u64, ErrorKind>
Sourcepub fn as_i128(&self, input: &[u8]) -> Result<i128, ErrorKind>
pub fn as_i128(&self, input: &[u8]) -> Result<i128, ErrorKind>
Decode the literal as i128. Routes through str::parse — 128-bit
JSON integers are rare enough that the bespoke fast paths used for
i64/u64 are not justified.
pub fn as_f64(&self, input: &[u8]) -> Result<f64, ErrorKind>
Trait Implementations§
impl Copy for JsonNum
impl Eq for JsonNum
impl StructuralPartialEq for JsonNum
Auto Trait Implementations§
impl Freeze for JsonNum
impl RefUnwindSafe for JsonNum
impl Send for JsonNum
impl Sync for JsonNum
impl Unpin for JsonNum
impl UnsafeUnpin for JsonNum
impl UnwindSafe for JsonNum
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more