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>) {
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,