pub(crate) fn from_vec(mut coverage: Vec<usize>) -> Result<Self, Error> {
        coverage.sort();
        let (lower, upper) = match (coverage.first(), coverage.last()) {
            (Some(first), Some(last)) => (*first, *last + 1),
            _ => return Err(format_err!("Can't build range from empty vec")),
        };
        let mut skip = HashSet::new();

        let mut prev = upper;
        for id in coverage.into_iter().rev() {
            if prev == id + 1 {
                prev = id;
            } else {
                // duplicate entries end up in this branch but don't get added since the range
                // (id + 1..prev) is empty
                skip.extend(id + 1..prev);

                prev = id;
            }
        }
        if !skip.is_empty() {
            Ok(Span::Discontinuous(SkipSpan::new(lower, upper, skip)))
        } else {
            Ok(Span::Continuous(ContinuousSpan::new(lower, upper)))
        }
    }
// Internally used constructor to build a span from a vec.
Internally used constructor to build a span from a vec.
Internally used constructor to build a span from a vec .
pub(crate) fn from_vec(mut coverage: Vec<usize>) -> Result<Self, Error> {
        coverage.sort();
        let (lower, upper) = match (coverage.first(), coverage.last()) {
            (Some(first), Some(last)) => (*first, *last + 1),
            _ => return Err(format_err!("Can't build range from empty vec")),
        };
        let mut skip = HashSet::new();
        let mut prev = upper;
        for id in coverage.into_iter().rev() {
            if prev == id + 1 {
                prev = id;
            } else {
                // duplicate entries end up in this branch but don't get added since the range
                // (id + 1..prev) is empty
                skip.extend(id + 1..prev);
                prev = id;
            }
        }
        if !skip.is_empty() {
            Ok(Span::Discontinuous(SkipSpan::new(lower, upper, skip)))
        } else {
            Ok(Span::Continuous(ContinuousSpan::new(lower, upper)))
        }
    }
pub ( crate ) fn from_vec ( mut coverage : Vec < usize > ) -> Result < Self , Error > { coverage . sort ( ) ; let ( lower , upper ) = match ( coverage . first ( ) , coverage . last ( ) ) { ( Some ( first ) , Some ( last ) ) => ( * first , * last + 1 ) , _ => return Err ( format_err ! ( " " ) ) , } ; let mut skip = HashSet :: new ( ) ; let mut prev = upper ; for id in coverage . into_iter ( ) . rev ( ) { if prev == id + 1 { prev = id ; } else { // duplicate entries end up in this branch but don't get added since the range // (id + 1..prev) is empty skip . extend ( id + 1 .. prev ) ; prev = id ; } } if ! skip . is_empty ( ) { Ok ( Span :: Discontinuous ( SkipSpan :: new ( lower , upper , skip ) ) ) } else { Ok ( Span :: Continuous ( ContinuousSpan :: new ( lower , upper ) ) ) } }
Internally used constructor to build a span from a vec.
Internally used constructor to build a span from a vec .
coverage
Vec<usize>
coverage
Vec<usize>