Skip to content

Commit 1f16e22

Browse files
committed
fixed awkward referencing within allergens
1 parent 0d6261b commit 1f16e22

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/parse/daily_menu/allergens.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::parse::Error;
44
use bitflags::bitflags;
55
use juniper::GraphQLObject;
66

7-
#[derive(Debug, PartialEq, Eq)]
7+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
88
pub struct AllergenInfo(AllergenFlags);
99

1010
impl AllergenInfo {
@@ -78,22 +78,14 @@ impl Display for AllergenInfo {
7878
}
7979
}
8080

81-
impl Deref for AllergenInfo {
82-
type Target = AllergenFlags;
83-
84-
fn deref(&self) -> &Self::Target {
85-
&self.0
86-
}
87-
}
88-
89-
impl Into<Vec<&'static str>> for &AllergenInfo {
90-
fn into(self) -> Vec<&'static str> {
91-
(&self.0).into()
81+
impl From<AllergenFlags> for AllergenInfo {
82+
fn from(flags: AllergenFlags) -> Self {
83+
Self(flags)
9284
}
9385
}
9486

9587
bitflags! {
96-
#[derive(Debug, PartialEq, Eq)]
88+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
9789
pub struct AllergenFlags: u16 {
9890
const Egg = 1;
9991
const Fish = 1 << 1;
@@ -147,6 +139,12 @@ impl Into<Vec<&'static str>> for &AllergenFlags {
147139
}
148140
}
149141

142+
impl Into<Vec<&'static str>> for AllergenFlags {
143+
fn into(self) -> Vec<&'static str> {
144+
(&self).into()
145+
}
146+
}
147+
150148
impl Display for AllergenFlags {
151149
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
152150
let allergens: Vec<&str> = self.into();

0 commit comments

Comments
 (0)