Remove clones
This commit is contained in:
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
mod mensa;
|
27
src/mensa.rs
27
src/mensa.rs
@@ -75,14 +75,13 @@ impl Mealplan for Mensa {
|
||||
|
||||
fn today(&self) -> (String, Vec<&Menu>) {
|
||||
let local = format!("{}", Local::now().format("%Y-%m-%d"));
|
||||
(
|
||||
local.clone(),
|
||||
self.canteen
|
||||
let menus = self
|
||||
.canteen
|
||||
.menus
|
||||
.iter()
|
||||
.filter(|&x| x.menu_date == local)
|
||||
.collect(),
|
||||
)
|
||||
.collect();
|
||||
(local, menus)
|
||||
}
|
||||
|
||||
fn nth(&self, days: u8, vegetarian: bool) -> Option<(String, Vec<&Menu>)> {
|
||||
@@ -90,23 +89,21 @@ impl Mealplan for Mensa {
|
||||
Some(dt) => {
|
||||
let local = format!("{}", dt.format("%Y-%m-%d"));
|
||||
if vegetarian {
|
||||
Some((
|
||||
local.clone(),
|
||||
self.canteen
|
||||
let menus = self
|
||||
.canteen
|
||||
.menus
|
||||
.iter()
|
||||
.filter(|&x| x.menu_date == local && x.menu_line.contains("veg"))
|
||||
.collect(),
|
||||
))
|
||||
.collect();
|
||||
Some((local, menus))
|
||||
} else {
|
||||
Some((
|
||||
local.clone(),
|
||||
self.canteen
|
||||
let menus = self
|
||||
.canteen
|
||||
.menus
|
||||
.iter()
|
||||
.filter(|&x| x.menu_date == local)
|
||||
.collect(),
|
||||
))
|
||||
.collect();
|
||||
Some((local, menus))
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
|
Reference in New Issue
Block a user