From a80bb8f77e90ff4632170a4a979a48f973e2fcbb Mon Sep 17 00:00:00 2001 From: "F. Levi" <55688616+flevi29@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:40:17 +0300 Subject: [PATCH] Misc --- meilisearch-types/src/keys.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/meilisearch-types/src/keys.rs b/meilisearch-types/src/keys.rs index ec0ec60a5..13ca0ab10 100644 --- a/meilisearch-types/src/keys.rs +++ b/meilisearch-types/src/keys.rs @@ -222,7 +222,6 @@ bitflags! { } impl Action { - // @TODO: Consider using https://github.com/rust-phf/rust-phf const SERDE_MAP_ARR: [(&'static str, Self); 34] = [ ("*", Self::All), ("search", Self::Search), @@ -272,7 +271,8 @@ impl Action { .iter() .find(|(_, ref action)| v == action) .map(|(ser_action, _)| ser_action) - .expect("`action_wanted` should always have a matching serialized value") + // actions should always have matching serialized values + .unwrap() } pub const fn from_repr(repr: u8) -> Option { @@ -399,10 +399,11 @@ impl Sequence for Action { } fn previous(&self) -> Option { - if self.bits() == 0 { + let current_index = self.bits() as usize; + if current_index == 0 { None } else { - Some(Self::SERDE_MAP_ARR[self.bits() as usize - 1].1) + Some(Self::SERDE_MAP_ARR[current_index - 1].1) } }