fn find_substring(&self, substring: Input<'b>) -> Option<usize> {
        let substring_length = substring.len();

        if substring_length == 0 {
            None
        } else if substring_length == 1 {
            memchr::memchr(substring[0], self.slice)
        } else {
            let max          = self.slice.len() - substring_length;
            let mut offset   = 0;
            let mut haystack = self.slice;

            while let Some(position) = memchr::memchr(substring[0], haystack) {
                offset += position;

                if offset > max {
                    return None
                }

                if &haystack[position..position + substring_length] == substring {
                    return Some(offset);
                }

                haystack  = &haystack[position + 1..];
                offset   += 1;
            }

            None
        }
    }
/// Find the position of a substring in the current span.
///
/// # Examples
///
/// ```
/// # extern crate tagua_parser;
/// # extern crate nom;
/// use tagua_parser::tokens::Span;
/// use nom::FindSubstring;
///
/// # fn main() {
/// assert_eq!(Span::new(b"foobar").find_substring(b"b"), Some(3));
/// # }
/// ```
Find the position of a substring in the current span.
Find the position of a substring in the current span .
fn find_substring(&self, substring: Input<'b>) -> Option<usize> {
        let substring_length = substring.len();
        if substring_length == 0 {
            None
        } else if substring_length == 1 {
            memchr::memchr(substring[0], self.slice)
        } else {
            let max          = self.slice.len() - substring_length;
            let mut offset   = 0;
            let mut haystack = self.slice;
            while let Some(position) = memchr::memchr(substring[0], haystack) {
                offset += position;
                if offset > max {
                    return None
                }
                if &haystack[position..position + substring_length] == substring {
                    return Some(offset);
                }
                haystack  = &haystack[position + 1..];
                offset   += 1;
            }
            None
        }
    }
fn find_substring ( & self , substring : Input < ' b > ) -> Option < usize > { let substring_length = substring . len ( ) ; if substring_length == 0 { None } else if substring_length == 1 { memchr :: memchr ( substring [ 0 ] , self . slice ) } else { let max = self . slice . len ( ) - substring_length ; let mut offset = 0 ; let mut haystack = self . slice ; while let Some ( position ) = memchr :: memchr ( substring [ 0 ] , haystack ) { offset += position ; if offset > max { return None } if & haystack [ position .. position + substring_length ] == substring { return Some ( offset ) ; } haystack = & haystack [ position + 1 .. ] ; offset += 1 ; } None } }
Find the position of a substring in the current span.
Find the position of a substring in the current span .
&self
substring
Input<'b>
examples
None
extern crate tagua_parser;
None
extern crate nom;
use tagua_parser::tokens::Span;
use nom::FindSubstring.
use tagua_parser :: tokens :: Span ; use nom :: FindSubstring .
fn main() {
None
}
None