pub struct SingleAmount<'ctx> { /* private fields */ }Expand description
Amount with only one commodity.
Implementations§
Source§impl<'ctx> SingleAmount<'ctx>
impl<'ctx> SingleAmount<'ctx>
Sourcepub fn from_value(value: Decimal, commodity: CommodityTag<'ctx>) -> Self
pub fn from_value(value: Decimal, commodity: CommodityTag<'ctx>) -> Self
Constructs an instance with single commodity.
Sourcepub fn check_add(self, rhs: Self) -> Result<Self, EvalError<'ctx>>
pub fn check_add(self, rhs: Self) -> Result<Self, EvalError<'ctx>>
Adds the amount with keeping commodity single.
Sourcepub fn check_sub(self, rhs: Self) -> Result<Self, EvalError<'ctx>>
pub fn check_sub(self, rhs: Self) -> Result<Self, EvalError<'ctx>>
Subtracts the amount with keeping the commodity single.
Sourcepub fn check_div(self, rhs: Decimal) -> Result<Self, EvalError<'ctx>>
pub fn check_div(self, rhs: Decimal) -> Result<Self, EvalError<'ctx>>
Divides by given Decimal.
Sourcepub fn round(self, ctx: &ReportContext<'_>) -> Self
pub fn round(self, ctx: &ReportContext<'_>) -> Self
Rounds the Amount with the given context provided precision.
Sourcepub fn as_display<'a>(
&'a self,
ctx: &'a ReportContext<'ctx>,
) -> impl Display + 'awhere
'a: 'ctx,
pub fn as_display<'a>(
&'a self,
ctx: &'a ReportContext<'ctx>,
) -> impl Display + 'awhere
'a: 'ctx,
Returns an instance which can be displayed.
Trait Implementations§
Source§impl<'ctx> Add<SingleAmount<'ctx>> for Amount<'ctx>
impl<'ctx> Add<SingleAmount<'ctx>> for Amount<'ctx>
Source§impl<'ctx> AddAssign<SingleAmount<'ctx>> for Amount<'ctx>
impl<'ctx> AddAssign<SingleAmount<'ctx>> for Amount<'ctx>
Source§fn add_assign(&mut self, rhs: SingleAmount<'ctx>)
fn add_assign(&mut self, rhs: SingleAmount<'ctx>)
Performs the
+= operation. Read moreSource§impl<'ctx> Clone for SingleAmount<'ctx>
impl<'ctx> Clone for SingleAmount<'ctx>
Source§fn clone(&self) -> SingleAmount<'ctx>
fn clone(&self) -> SingleAmount<'ctx>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'ctx> Debug for SingleAmount<'ctx>
impl<'ctx> Debug for SingleAmount<'ctx>
Source§impl<'ctx> From<SingleAmount<'ctx>> for Amount<'ctx>
impl<'ctx> From<SingleAmount<'ctx>> for Amount<'ctx>
Source§fn from(value: SingleAmount<'ctx>) -> Self
fn from(value: SingleAmount<'ctx>) -> Self
Converts to this type from the input type.
Source§impl Mul<Decimal> for SingleAmount<'_>
impl Mul<Decimal> for SingleAmount<'_>
Source§impl Neg for SingleAmount<'_>
impl Neg for SingleAmount<'_>
Source§impl<'ctx> PartialEq for SingleAmount<'ctx>
impl<'ctx> PartialEq for SingleAmount<'ctx>
Source§impl<'ctx> TryFrom<&Amount<'ctx>> for SingleAmount<'ctx>
impl<'ctx> TryFrom<&Amount<'ctx>> for SingleAmount<'ctx>
Source§impl<'ctx> TryFrom<Amount<'ctx>> for SingleAmount<'ctx>
impl<'ctx> TryFrom<Amount<'ctx>> for SingleAmount<'ctx>
impl<'ctx> Copy for SingleAmount<'ctx>
impl<'ctx> Eq for SingleAmount<'ctx>
impl<'ctx> StructuralPartialEq for SingleAmount<'ctx>
Auto Trait Implementations§
impl<'ctx> Freeze for SingleAmount<'ctx>
impl<'ctx> RefUnwindSafe for SingleAmount<'ctx>
impl<'ctx> Send for SingleAmount<'ctx>
impl<'ctx> Sync for SingleAmount<'ctx>
impl<'ctx> Unpin for SingleAmount<'ctx>
impl<'ctx> UnwindSafe for SingleAmount<'ctx>
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