mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Fix erroneous Sequence impl
This commit is contained in:
parent
ccd79b07f7
commit
c2b14b8f8f
@ -413,11 +413,9 @@ impl Sequence for Action {
|
|||||||
let mut potential_next_index = self.get_potential_index() + 1;
|
let mut potential_next_index = self.get_potential_index() + 1;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(next_flag) = Self::FLAGS.get(potential_next_index) {
|
if let Some(next_flag) = Self::FLAGS.get(potential_next_index).map(|v| v.value()) {
|
||||||
let next_flag_value = next_flag.value();
|
if next_flag > self {
|
||||||
|
return Some(*next_flag);
|
||||||
if next_flag_value > self {
|
|
||||||
return Some(*next_flag_value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
potential_next_index += 1;
|
potential_next_index += 1;
|
||||||
@ -429,18 +427,25 @@ impl Sequence for Action {
|
|||||||
|
|
||||||
fn previous(&self) -> Option<Self> {
|
fn previous(&self) -> Option<Self> {
|
||||||
// -2 because of "all" type flags that represent a single flag, otherwise -1 would suffice
|
// -2 because of "all" type flags that represent a single flag, otherwise -1 would suffice
|
||||||
let mut potential_previous_index = self.get_potential_index() - 2;
|
let initial_potential_index = self.get_potential_index();
|
||||||
|
if initial_potential_index == 0 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut potential_previous_index: usize =
|
||||||
|
if initial_potential_index == 1 { 0 } else { initial_potential_index - 2 };
|
||||||
|
|
||||||
let mut previous_item: Option<Self> = None;
|
let mut previous_item: Option<Self> = None;
|
||||||
|
let mut pre_previous_item: Option<Self> = None;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if let Some(next_flag) = Self::FLAGS.get(potential_previous_index) {
|
if let Some(next_flag) = Self::FLAGS.get(potential_previous_index).map(|v| v.value()) {
|
||||||
let next_flag_value = next_flag.value();
|
if next_flag > self {
|
||||||
|
return pre_previous_item;
|
||||||
if next_flag_value > self {
|
|
||||||
return previous_item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
previous_item = Some(*next_flag_value);
|
pre_previous_item = previous_item;
|
||||||
|
previous_item = Some(*next_flag);
|
||||||
potential_previous_index += 1;
|
potential_previous_index += 1;
|
||||||
} else {
|
} else {
|
||||||
return None;
|
return None;
|
||||||
|
Loading…
Reference in New Issue
Block a user