pub struct BillItem<P> {
pub amount: Amount,
pub product: P,
}
Expand description
Maps a BillProduct
to an amount.
Fields§
§amount: Amount
§product: P
Implementations§
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)
11 12 13 14 15 16 17 18 19 20 21 22
fn print_items(items: &[BillItem<Product<'_>>]) {
//println!("{:?}", items);
for item in items {
println!(
" * {:3}x {:15} {:6} {:6}",
item.amount,
item.product.name,
item.product.price.postfix(),
item.gross().postfix()
);
}
}