Remove clones
This commit is contained in:
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
mod mensa;
|
45
src/mensa.rs
45
src/mensa.rs
@@ -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,
|
||||||
|
Reference in New Issue
Block a user