pub fn for_slices_u16<'a, F>(data: &'a [u8], mut f: F) where F: FnMut(&'a [u8]) -> bool {
    let mut left = data;

    while left.len() > 2 {
        // Read a 16-bit length prefix.
        let len = (left[0] as usize) << 8 | (left[1] as usize);

        // Stop on invalid lengths, rather than capping the slice. This improves
        // the chances of byte strings combining in interesting ways.
        if len > left.len() - 2 { break }

        if !f(&left[2..2 + len]) { break }
        left = &left[2 + len..];
    }
}
/// Evaluate a closure on byte slices of various lengths, up to 2^16.
Evaluate a closure on byte slices of various lengths, up to 2^16.
Evaluate a closure on byte slices of various lengths up to 2^16 .
pub fn for_slices_u16<'a, F>(data: &'a [u8], mut f: F) where F: FnMut(&'a [u8]) -> bool {
    let mut left = data;
    while left.len() > 2 {
        // Read a 16-bit length prefix.
        let len = (left[0] as usize) << 8 | (left[1] as usize);
        // Stop on invalid lengths, rather than capping the slice. This improves
        // the chances of byte strings combining in interesting ways.
        if len > left.len() - 2 { break }
        if !f(&left[2..2 + len]) { break }
        left = &left[2 + len..];
    }
}
pub fn for_slices_u16 < ' a , F > ( data : & ' a [ u8 ] , mut f : F ) where F : FnMut ( & ' a [ u8 ] ) -> bool { let mut left = data ; while left . len ( ) > 2 { // Read a 16-bit length prefix. let len = ( left [ 0 ] as usize ) << 8 | ( left [ 1 ] as usize ) ; // Stop on invalid lengths, rather than capping the slice. This improves // the chances of byte strings combining in interesting ways. if len > left . len ( ) - 2 { break } if ! f ( & left [ 2 .. 2 + len ] ) { break } left = & left [ 2 + len .. ] ; } }
Evaluate a closure on byte slices of various lengths, up to 2^16.
Evaluate a closure on byte slices of various lengths up to 2^16 .
data
&'a [u8]
f
F
data
&'a [u8]
f
F