pub fn not_line_ending<T>(input: T) -> IResult<T, T>
where
  T: Slice<Range<usize>> + Slice<RangeFrom<usize>> + Slice<RangeTo<usize>>,
  T: InputIter + InputLength + AtEof,
  T: Compare<&'static str>,
  <T as InputIter>::Item: AsChar,
  <T as InputIter>::RawItem: AsChar,
{
  match input.position(|item| {
    let c = item.as_char();
    c == '\r' || c == '\n'
  }) {
    None => {
      if input.at_eof() {
        Ok((input.slice(input.input_len()..), input))
      } else {
        Err(Err::Incomplete(Needed::Unknown))
      }
    }
    Some(index) => {
      let mut it = input.slice(index..).iter_elements();
      let nth = it.next().unwrap().as_char();
      if nth == '\r' {
        let sliced = input.slice(index..);
        let comp = sliced.compare("\r\n");
        match comp {
          //FIXME: calculate the right index
          CompareResult::Incomplete => need_more_err(input, Needed::Unknown, ErrorKind::Tag),
          CompareResult::Error => {
            let e: ErrorKind<u32> = ErrorKind::Tag;
            Err(Err::Error(error_position!(input, e)))
          }
          CompareResult::Ok => Ok((input.slice(index..), input.slice(..index))),
        }
      } else {
        Ok((input.slice(index..), input.slice(..index)))
      }
    }
  }
}
// FIXME: when rust-lang/rust#17436 is fixed, macros will be able to export
// public methods
when rust-lang/rust#17436 is fixed, macros will be able to export
public methods
when rust - lang / rust#17436 is fixed macros will be able to export public methods
pub fn not_line_ending<T>(input: T) -> IResult<T, T>
where
  T: Slice<Range<usize>> + Slice<RangeFrom<usize>> + Slice<RangeTo<usize>>,
  T: InputIter + InputLength + AtEof,
  T: Compare<&'static str>,
  <T as InputIter>::Item: AsChar,
  <T as InputIter>::RawItem: AsChar,
{
  match input.position(|item| {
    let c = item.as_char();
    c == '\r' || c == '\n'
  }) {
    None => {
      if input.at_eof() {
        Ok((input.slice(input.input_len()..), input))
      } else {
        Err(Err::Incomplete(Needed::Unknown))
      }
    }
    Some(index) => {
      let mut it = input.slice(index..).iter_elements();
      let nth = it.next().unwrap().as_char();
      if nth == '\r' {
        let sliced = input.slice(index..);
        let comp = sliced.compare("\r\n");
        match comp {
          //FIXME: calculate the right index
          CompareResult::Incomplete => need_more_err(input, Needed::Unknown, ErrorKind::Tag),
          CompareResult::Error => {
            let e: ErrorKind<u32> = ErrorKind::Tag;
            Err(Err::Error(error_position!(input, e)))
          }
          CompareResult::Ok => Ok((input.slice(index..), input.slice(..index))),
        }
      } else {
        Ok((input.slice(index..), input.slice(..index)))
      }
    }
  }
}
pub fn not_line_ending < T > ( input : T ) -> IResult < T , T > where T : Slice < Range < usize > > + Slice < RangeFrom < usize > > + Slice < RangeTo < usize > > , T : InputIter + InputLength + AtEof , T : Compare < & ' static str > , < T as InputIter > :: Item : AsChar , < T as InputIter > :: RawItem : AsChar , { match input . position ( | item | { let c = item . as_char ( ) ; c == '\r' || c == '\n' } ) { None => { if input . at_eof ( ) { Ok ( ( input . slice ( input . input_len ( ) .. ) , input ) ) } else { Err ( Err :: Incomplete ( Needed :: Unknown ) ) } } Some ( index ) => { let mut it = input . slice ( index .. ) . iter_elements ( ) ; let nth = it . next ( ) . unwrap ( ) . as_char ( ) ; if nth == '\r' { let sliced = input . slice ( index .. ) ; let comp = sliced . compare ( " \r \n " ) ; match comp { //FIXME: calculate the right index CompareResult :: Incomplete => need_more_err ( input , Needed :: Unknown , ErrorKind :: Tag ) , CompareResult :: Error => { let e : ErrorKind < u32 > = ErrorKind :: Tag ; Err ( Err :: Error ( error_position ! ( input e ) ) ) } CompareResult :: Ok => Ok ( ( input . slice ( index .. ) , input . slice ( .. index ) ) ) , } } else { Ok ( ( input . slice ( index .. ) , input . slice ( .. index ) ) ) } } } }
FIXME: when rust-lang/rust#17436 is fixed, macros will be able to export
public methods
FIXME : when rust - lang / rust#17436 is fixed macros will be able to export public methods
input
T
input
T