pub struct BillItem<P> {
pub amount: Amount,
pub product: P,
}Expand description
Maps a BillProduct to an amount.
Fieldsยง
ยงamount: Amountยงproduct: PImplementationsยง
Sourceยงimpl<P: BillProduct> BillItem<P>
impl<P: BillProduct> BillItem<P>
Sourcepub fn gross(&self) -> Money
pub fn gross(&self) -> Money
price * amount
Examples found in repository?
examples/catalogue.rs (line 19)
11fn print_items(items: &[BillItem<Product<'_>>]) {
12 //println!("{:?}", items);
13 for item in items {
14 println!(
15 " * {:3}x {:15} {:6} {:6}",
16 item.amount,
17 item.product.name,
18 item.product.price.postfix(),
19 item.gross().postfix()
20 );
21 }
22}Trait Implementationsยง
Auto Trait Implementationsยง
impl<P> Freeze for BillItem<P>where
P: Freeze,
impl<P> RefUnwindSafe for BillItem<P>where
P: RefUnwindSafe,
impl<P> Send for BillItem<P>where
P: Send,
impl<P> Sync for BillItem<P>where
P: Sync,
impl<P> Unpin for BillItem<P>where
P: Unpin,
impl<P> UnwindSafe for BillItem<P>where
P: UnwindSafe,
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