Skip to main content

serde_json/lexical/
bignum.rs

1// Adapted from https://github.com/Alexhuszagh/rust-lexical.
2
3//! Big integer type definition.
4
5use super::math::*;
6#[allow(unused_imports)]
7use alloc::vec::Vec;
8
9/// Storage for a big integer type.
10#[derive(#[automatically_derived]
impl ::core::clone::Clone for Bigint {
    #[inline]
    fn clone(&self) -> Self {
        Self { data: ::core::clone::Clone::clone(&self.data) }
    }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for Bigint { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Bigint {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.data == other.data }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Bigint {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Vec<Limb>>;
    }
}Eq)]
11pub(crate) struct Bigint {
12    /// Internal storage for the Bigint, in little-endian order.
13    pub(crate) data: Vec<Limb>,
14}
15
16impl Default for Bigint {
17    fn default() -> Self {
18        Bigint {
19            data: Vec::with_capacity(20),
20        }
21    }
22}
23
24impl Math for Bigint {
25    #[inline]
26    fn data(&self) -> &Vec<Limb> {
27        &self.data
28    }
29
30    #[inline]
31    fn data_mut(&mut self) -> &mut Vec<Limb> {
32        &mut self.data
33    }
34}