Remove clones

This commit is contained in:
2024-12-29 00:39:44 +01:00
parent 577896c6ad
commit be1542bbe8
2 changed files with 22 additions and 24 deletions

1
src/lib.rs Normal file
View File

@@ -0,0 +1 @@
mod mensa;

View File

@@ -75,14 +75,13 @@ impl Mealplan for Mensa {
fn today(&self) -> (String, Vec<&Menu>) { fn today(&self) -> (String, Vec<&Menu>) {
let local = format!("{}", Local::now().format("%Y-%m-%d")); let local = format!("{}", Local::now().format("%Y-%m-%d"));
( let menus = self
local.clone(), .canteen
self.canteen
.menus .menus
.iter() .iter()
.filter(|&x| x.menu_date == local) .filter(|&x| x.menu_date == local)
.collect(), .collect();
) (local, menus)
} }
fn nth(&self, days: u8, vegetarian: bool) -> Option<(String, Vec<&Menu>)> { fn nth(&self, days: u8, vegetarian: bool) -> Option<(String, Vec<&Menu>)> {
@@ -90,23 +89,21 @@ impl Mealplan for Mensa {
Some(dt) => { Some(dt) => {
let local = format!("{}", dt.format("%Y-%m-%d")); let local = format!("{}", dt.format("%Y-%m-%d"));
if vegetarian { if vegetarian {
Some(( let menus = self
local.clone(), .canteen
self.canteen
.menus .menus
.iter() .iter()
.filter(|&x| x.menu_date == local && x.menu_line.contains("veg")) .filter(|&x| x.menu_date == local && x.menu_line.contains("veg"))
.collect(), .collect();
)) Some((local, menus))
} else { } else {
Some(( let menus = self
local.clone(), .canteen
self.canteen
.menus .menus
.iter() .iter()
.filter(|&x| x.menu_date == local) .filter(|&x| x.menu_date == local)
.collect(), .collect();
)) Some((local, menus))
} }
} }
_ => None, _ => None,