Skip to content

Commit d5becf4

Browse files
committed
clippy errors
1 parent cade90f commit d5becf4

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

src/parse/daily_menu/allergens.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl AllergenInfo {
1111
// use reduce to or the allergen flags
1212
let allergen_flags = elements
1313
.filter_map(|element| element.value().attr("src"))
14-
.map(|img_url| Self::img_url_to_allergen(img_url));
14+
.map(Self::img_url_to_allergen);
1515
// if there is an error, return the error via a for loop
1616
let mut acc = AllergenFlags::empty();
1717
for allergen_flag in allergen_flags {
@@ -72,31 +72,27 @@ impl AllergenInfo {
7272
bitflags! {
7373
#[derive(Debug, PartialEq, Eq)]
7474
pub struct AllergenFlags: u16 {
75-
const Egg = 0b0000000000000001;
76-
const Fish = 0b0000000000000010;
77-
const GlutenFriendly = 0b0000000000000100;
78-
const Milk = 0b000000000001000;
79-
const Peanut = 0b0000000000010000;
80-
const Soy = 0b0000000000100000;
81-
const TreeNut = 0b0000000001000000;
82-
const Alcohol = 0b0000000010000000;
83-
const Vegan = 0b0000000100000000;
84-
const Vegetarian = 0b0000001000000000;
85-
const Pork = 0b0000010000000000;
86-
const Beef = 0b0000100000000000;
87-
const Halal = 0b0001000000000000;
88-
const Shellfish = 0b0010000000000000;
89-
const Sesame = 0b0100000000000000;
75+
const Egg = 1;
76+
const Fish = 1 << 1;
77+
const GlutenFriendly = 1 << 2;
78+
const Milk = 1 << 3;
79+
const Peanut = 1 << 4;
80+
const Soy = 1 << 5;
81+
const TreeNut = 1 << 6;
82+
const Alcohol = 1 << 7;
83+
const Vegan = 1 << 8;
84+
const Vegetarian = 1 << 9;
85+
const Pork = 1 << 10;
86+
const Beef = 1 << 11;
87+
const Halal = 1 << 12;
88+
const Shellfish = 1 << 13;
89+
const Sesame = 1 << 14;
9090
}
9191
}
9292

9393
#[cfg(test)]
9494

9595
mod tests {
96-
use std::sync::OnceLock;
97-
98-
use scraper::Selector;
99-
10096
use crate::static_selector;
10197

10298
use super::*;
@@ -170,7 +166,6 @@ mod tests {
170166
// source: https://nutrition.sa.ucsc.edu/allergenfilter.aspx?strcurlocationnum=40
171167

172168
let doc = scraper::Html::parse_document(HTML);
173-
static SELECTOR: OnceLock<Selector> = OnceLock::new();
174169
static_selector!(DATE_SELECTOR <- "img");
175170
let mut all_allergen_flags = AllergenFlags::empty();
176171
for element in doc.select(&DATE_SELECTOR) {
@@ -183,6 +178,6 @@ mod tests {
183178
all_allergen_flags |= allergen_flags;
184179
}
185180
// ensure that all the allergen flags are picked up properly
186-
assert!(all_allergen_flags.is_all())
181+
assert!(all_allergen_flags.is_all());
187182
}
188183
}

src/parse/daily_menu/daily_menu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl PartialEq for DailyMenu<'_> {
1818

1919
impl PartialOrd for DailyMenu<'_> {
2020
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
21-
self.date.partial_cmp(&other.date)
21+
Some(self.cmp(other))
2222
}
2323
}
2424

0 commit comments

Comments
 (0)