pub struct MixedNumber(pub RBig);Expand description
Newtype wrapper providing FromStr for the mixed-number format.
RBig already implements FromStr for the standard "a/b" syntax;
this newtype extends parsing to also accept "1 3/4" while keeping
the orphan rule satisfied.
§Examples
use oxinum_rational::{MixedNumber, RBig, IBig, UBig};
use std::str::FromStr;
let m: MixedNumber = "1 3/4".parse().unwrap();
assert_eq!(m.0, RBig::from_parts(IBig::from(7), UBig::from(4u32)));
let n = MixedNumber::from_str("-2 1/3").unwrap();
assert_eq!(n.0, RBig::from_parts(IBig::from(-7), UBig::from(3u32)));Tuple Fields§
§0: RBigTrait Implementations§
Source§impl Clone for MixedNumber
impl Clone for MixedNumber
Source§fn clone(&self) -> MixedNumber
fn clone(&self) -> MixedNumber
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MixedNumber
impl Debug for MixedNumber
Source§impl Display for MixedNumber
impl Display for MixedNumber
impl Eq for MixedNumber
Source§impl FromStr for MixedNumber
impl FromStr for MixedNumber
Source§impl PartialEq for MixedNumber
impl PartialEq for MixedNumber
Source§fn eq(&self, other: &MixedNumber) -> bool
fn eq(&self, other: &MixedNumber) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for MixedNumber
Auto Trait Implementations§
impl Freeze for MixedNumber
impl RefUnwindSafe for MixedNumber
impl Send for MixedNumber
impl Sync for MixedNumber
impl Unpin for MixedNumber
impl UnsafeUnpin for MixedNumber
impl UnwindSafe for MixedNumber
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