pub struct Items {
pub food: HashMap<String, f64>,
pub drinks: HashMap<String, f64>,
pub sides: HashMap<String, f64>,
}
Fields§
§food: HashMap<String, f64>
§drinks: HashMap<String, f64>
§sides: HashMap<String, f64>
Implementations§
Source§impl Items
impl Items
Sourcepub fn new(
food: HashMap<String, f64>,
drinks: HashMap<String, f64>,
sides: HashMap<String, f64>,
) -> Self
pub fn new( food: HashMap<String, f64>, drinks: HashMap<String, f64>, sides: HashMap<String, f64>, ) -> Self
§New instance function
@prams: food: vector of food items drinks: vector of drinks sides: vector of sides @return: instance of type Items
§Panics
The function panics if the second argument is zero.
use std::collections::HashMap;
use map_macro::hash_map;
use dit_as_91896::food::Items;
let food: HashMap<String, f64> = hash_map! {
String::from("0") => 0.0,
};
let drinks: HashMap<String, f64> = hash_map! {
String::from("1") => 1.0,
};
let sides: HashMap<String, f64> = hash_map! {
String::from("2") => 2.0,
};
let items: Items = Items::new(food.clone(), drinks.clone(), sides.clone());
assert!(items.food == food);
assert!(items.drinks == drinks );
assert!(items.sides == sides);
Trait Implementations§
Source§impl Display for Items
impl Display for Items
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Fmt function allows the struct/type to be printed to the console
use map_macro::hash_map;
use dit_as_91896::food::Items;
let items: Items = Items {
food: hash_map! {
String::from("0") => 0.0,
},
drinks: hash_map! {
String::from("1") => 1.0,
},
sides: hash_map! {
String::from("2") => 2.0,
},
};
assert!(format!("{items}").as_str() == "food: {0: costs $0.00}, drinks: {1: costs $1.00}, sides: {2: costs $2.00}");
Auto Trait Implementations§
impl Freeze for Items
impl RefUnwindSafe for Items
impl Send for Items
impl Sync for Items
impl Unpin for Items
impl UnwindSafe for Items
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