git-async 0.1.1

An async-first library for reading git repositories
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use core::ops::Range;

pub(crate) trait SubsliceRange {
    fn subslice_range_stable(&self, subslice: &Self) -> Option<Range<usize>>;
}

impl<T> SubsliceRange for [T] {
    fn subslice_range_stable(&self, subslice: &[T]) -> Option<Range<usize>> {
        let first = subslice.first()?;
        let start = self.element_offset(first)?;
        let end = start + subslice.len();
        Some(Range { start, end })
    }
}