pub struct Amount { /* private fields */ }Expand description
A rational with a positive denominator.
Implementations§
Source§impl Amount
impl Amount
Sourcepub fn new(numer: i64, denom: i64) -> Option<Self>
pub fn new(numer: i64, denom: i64) -> Option<Self>
None unless the denominator is positive; i64::MIN has no written
form the reader accepts.
Sourcepub fn parse(text: &str) -> Result<Self, NotAnAmount>
pub fn parse(text: &str) -> Result<Self, NotAnAmount>
The reader’s number grammar: n, n/d, decimals and %, signed,
reduced to lowest terms.
§Errors
NotAnAmount for anything else, a zero denominator or an overflow.
pub fn numer(self) -> i64
pub fn denom(self) -> i64
Trait Implementations§
impl Copy for Amount
impl Eq for Amount
impl StructuralPartialEq for Amount
Auto Trait Implementations§
impl Freeze for Amount
impl RefUnwindSafe for Amount
impl Send for Amount
impl Sync for Amount
impl Unpin for Amount
impl UnsafeUnpin for Amount
impl UnwindSafe for Amount
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