pub struct TextCodedInteger { /* private fields */ }Expand description
A pedagogical integer type stored as decimal digits in a string.
All arithmetic is performed manually on the string representation, digit by digit. Values are
kept in canonical form (no leading zeros, no -0), so equality is equality of values, and
ordering compares values, not text.
Implementations§
Source§impl TextCodedInteger
impl TextCodedInteger
Sourcepub fn div_mod_manual(dividend: &Self, divisor: &Self) -> (Self, Self)
pub fn div_mod_manual(dividend: &Self, divisor: &Self) -> (Self, Self)
Manual long division: returns (quotient, remainder) Full manual long division: returns (quotient, remainder)
Trait Implementations§
Source§impl Add for TextCodedInteger
impl Add for TextCodedInteger
Source§impl CheckedAdd for TextCodedInteger
impl CheckedAdd for TextCodedInteger
Source§fn checked_add(&self, rhs: &Self) -> Option<Self>
fn checked_add(&self, rhs: &Self) -> Option<Self>
Adds two numbers, checking for overflow. If overflow happens,
None is
returned.Source§impl CheckedDiv for TextCodedInteger
impl CheckedDiv for TextCodedInteger
Source§fn checked_div(&self, rhs: &Self) -> Option<Self>
fn checked_div(&self, rhs: &Self) -> Option<Self>
None for division by zero.
Source§impl CheckedMul for TextCodedInteger
impl CheckedMul for TextCodedInteger
Source§fn checked_mul(&self, rhs: &Self) -> Option<Self>
fn checked_mul(&self, rhs: &Self) -> Option<Self>
Never overflows: the digit string grows as needed.
Source§impl CheckedSub for TextCodedInteger
impl CheckedSub for TextCodedInteger
Source§fn checked_sub(&self, rhs: &Self) -> Option<Self>
fn checked_sub(&self, rhs: &Self) -> Option<Self>
Subtracts two numbers, checking for underflow. If underflow happens,
None is returned.Source§impl Clone for TextCodedInteger
impl Clone for TextCodedInteger
Source§impl Debug for TextCodedInteger
impl Debug for TextCodedInteger
Source§impl Default for TextCodedInteger
impl Default for TextCodedInteger
Source§impl Display for TextCodedInteger
impl Display for TextCodedInteger
Source§impl Div for TextCodedInteger
impl Div for TextCodedInteger
impl Eq for TextCodedInteger
Source§impl Mul for TextCodedInteger
impl Mul for TextCodedInteger
Source§impl Neg for TextCodedInteger
impl Neg for TextCodedInteger
Source§impl Num for TextCodedInteger
impl Num for TextCodedInteger
type FromStrRadixErr = ParseIntError
Source§fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
Convert from a string and radix (typically
2..=36). Read moreSource§impl One for TextCodedInteger
impl One for TextCodedInteger
Source§impl Ord for TextCodedInteger
Numeric order: by sign, then by magnitude (more digits is larger; equal lengths compare
digit by digit), reversed for negative numbers.
impl Ord for TextCodedInteger
Numeric order: by sign, then by magnitude (more digits is larger; equal lengths compare digit by digit), reversed for negative numbers.
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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for TextCodedInteger
impl PartialEq for TextCodedInteger
Source§impl PartialOrd for TextCodedInteger
impl PartialOrd for TextCodedInteger
Source§impl Rem for TextCodedInteger
impl Rem for TextCodedInteger
Source§impl Signed for TextCodedInteger
impl Signed for TextCodedInteger
Source§fn abs_sub(&self, rhs: &Self) -> Self
fn abs_sub(&self, rhs: &Self) -> Self
The positive difference max(self − rhs, 0), as num_traits defines it.
Source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Returns true if the number is positive and false if the number is zero or negative.
Source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Returns true if the number is negative and false if the number is zero or positive.
impl StructuralPartialEq for TextCodedInteger
Source§impl Sub for TextCodedInteger
impl Sub for TextCodedInteger
Auto Trait Implementations§
impl Freeze for TextCodedInteger
impl RefUnwindSafe for TextCodedInteger
impl Send for TextCodedInteger
impl Sync for TextCodedInteger
impl Unpin for TextCodedInteger
impl UnsafeUnpin for TextCodedInteger
impl UnwindSafe for TextCodedInteger
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