This commit is contained in:
Paul Masurel
2019-01-28 03:46:23 +01:00
parent 2fb219d017
commit 1fd46c1e9b
4 changed files with 6 additions and 7 deletions

View File

@@ -69,8 +69,8 @@ pub fn serialize_vint_u32(val: u32) -> (u64, usize) {
/// # May Panic
/// If the payload does not start by a valid `vint`
fn vint_len(data: &[u8]) -> usize {
for i in 0..5.min(data.len()) {
if data[i] >= STOP_BIT {
for (i, &val) in data.iter().enumerate().take(5) {
if val >= STOP_BIT {
return i + 1;
}
}

View File

@@ -41,6 +41,6 @@ impl SegmentComponent {
SegmentComponent::STORE,
SegmentComponent::DELETE,
];
SEGMENT_COMPONENTS.into_iter()
SEGMENT_COMPONENTS.iter()
}
}

View File

@@ -26,8 +26,8 @@ pub fn intersect_scorers(mut scorers: Vec<Box<Scorer>>) -> Box<Scorer> {
(Some(single_docset), None) => single_docset,
(Some(left), Some(right)) => {
{
let all_term_scorers = [&left, &right].into_iter().all(|scorer| {
let scorer_ref: &Scorer = (*scorer).borrow();
let all_term_scorers = [&left, &right].iter().all(|&scorer| {
let scorer_ref: &Scorer = <Box<Scorer> as Borrow<Scorer>>::borrow(scorer);
Downcast::<TermScorer>::is_type(scorer_ref)
});
if all_term_scorers {

View File

@@ -27,9 +27,8 @@ pub enum Language {
}
impl Language {
fn algorithm(&self) -> Algorithm {
fn algorithm(self) -> Algorithm {
use self::Language::*;
match self {
Arabic => Algorithm::Arabic,
Danish => Algorithm::Danish,