Move empty range function into algorithm utils

This commit is contained in:
Armin Ronacher 2021-02-20 20:58:01 +01:00
parent 1cc4ec4d25
commit 5a24bb8652
5 changed files with 10 additions and 8 deletions

View file

@ -6,8 +6,8 @@ use std::collections::BTreeMap;
use std::ops::{Index, Range};
use std::time::Instant;
use crate::algorithms::utils::is_empty_range;
use crate::algorithms::DiffHook;
use crate::utils::is_empty_range;
/// HuntMcIlroy / HuntSzymanski LCS diff algorithm.
///

View file

@ -36,6 +36,7 @@
mod capture;
mod hook;
mod replace;
mod utils;
use std::hash::Hash;
use std::ops::{Index, Range};

View file

@ -22,8 +22,8 @@
use std::ops::{Index, IndexMut, Range};
use std::time::Instant;
use crate::algorithms::utils::is_empty_range;
use crate::algorithms::DiffHook;
use crate::utils::is_empty_range;
/// Myers' diff algorithm.
///

7
src/algorithms/utils.rs Normal file
View file

@ -0,0 +1,7 @@
use std::ops::Range;
/// Utility function to check if a range is empty that works on older rust versions
#[inline(always)]
pub(crate) fn is_empty_range<T: PartialOrd>(range: &Range<T>) -> bool {
!(range.start < range.end)
}