pub struct Int { /* private fields */ }Expand description
A signed integer of arbitrary size.
use ion_rs::{Element, Int};
let element = Element::read_one("-42")?;
// Access the element's integer value...
let int: &Int = element.expect_int()?;
// ...and convert it to an i64. `as_i64()` will return `None` if
// the Int is too large to fit in an i64.
assert_eq!(int.as_i64(), Some(-42i64));
// The `expect_i64()` is similar to `as_i64()`, but returns an
// `IonError` instead of `None` if the conversion cannot be completed.
assert_eq!(element.expect_i64()?, -42i64);Implementations§
Source§impl Int
impl Int
pub const ZERO: Int
Sourcepub fn unsigned_abs(&self) -> UInt
pub fn unsigned_abs(&self) -> UInt
Returns a UInt representing the unsigned magnitude of this Int.
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns true if this value is less than zero.
If this value is greater than or equal to zero, returns false.
Sourcepub fn expect_i64(&self) -> IonResult<i64>
pub fn expect_i64(&self) -> IonResult<i64>
If this value is small enough to fit in an i64, returns Ok(i64). Otherwise,
returns a DecodingError.
pub fn as_u32(&self) -> Option<u32>
pub fn expect_u32(&self) -> IonResult<u32>
pub fn as_u64(&self) -> Option<u64>
pub fn expect_u64(&self) -> IonResult<u64>
pub fn as_usize(&self) -> Option<usize>
pub fn expect_usize(&self) -> IonResult<usize>
Sourcepub fn expect_i128(&self) -> IonResult<i128>
pub fn expect_i128(&self) -> IonResult<i128>
If this value is small enough to fit in an i128, returns Ok(i128). Otherwise,
returns a DecodingError.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
If this value is small enough to fit in an i64, returns Some(i64). Otherwise, returns
None.
Sourcepub fn as_i128(&self) -> Option<i128>
pub fn as_i128(&self) -> Option<i128>
If this value is small enough to fit in an i128, returns Some(i128). Otherwise, returns
None.
pub fn from_le_signed_bytes(bytes: &[u8]) -> Int
pub fn to_le_signed_bytes(&self) -> Vec<u8> ⓘ
Trait Implementations§
impl Eq for Int
Source§impl From<Int> for Coefficient
impl From<Int> for Coefficient
Source§fn from(value: Int) -> Coefficient
fn from(value: Int) -> Coefficient
Converts to this type from the input type.
Source§impl Ord for Int
impl Ord for Int
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Int
impl PartialOrd for Int
impl StructuralPartialEq for Int
Source§impl TryFrom<&Coefficient> for Int
impl TryFrom<&Coefficient> for Int
Source§impl TryFrom<Coefficient> for Int
impl TryFrom<Coefficient> for Int
Auto Trait Implementations§
impl Freeze for Int
impl RefUnwindSafe for Int
impl Send for Int
impl Sync for Int
impl Unpin for Int
impl UnsafeUnpin for Int
impl UnwindSafe for Int
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<V> IntoAnnotatedElement for V
impl<V> IntoAnnotatedElement for V
Source§fn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element
fn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element
Converts the value into an Element with the specified annotations.
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more