Skip to content

Commit

Permalink
Illustrate take_till vs take_till1
Browse files Browse the repository at this point in the history
  • Loading branch information
willmurphyscode committed Oct 16, 2017
1 parent f3c2756 commit c4c045b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ macro_rules! take_while1 (
///
/// let r = till_colon(&b"abcd:efgh"[..]);
/// assert_eq!(r, Done(&b":efgh"[..], &b"abcd"[..]));
/// let r2 = till_colon(&b":abcdefgh"[..]); // empty match is allowed
/// assert_eq!(r2, Done(&b":abcdefgh"[..], &b""[..]));
/// # }
/// ```
#[macro_export]
Expand All @@ -477,6 +479,19 @@ macro_rules! take_till (
/// returns the longest non empty list of bytes until the provided function succeeds
///
/// The argument is either a function `&[T] -> bool` or a macro returning a `bool
///
/// ```
/// # #[macro_use] extern crate nom;
/// # use nom::IResult::{Done, Error};
/// # fn main() {
/// named!( till1_colon, take_till1!(|ch| ch == b":"[0]) );
///
/// let r = till1_colon(&b"abcd:efgh"[..]);
/// assert_eq!(r, Done(&b":efgh"[..], &b"abcd"[..]));
/// let r2 = till1_colon(&b":abcdefgh"[..]); // empty match is error
/// assert_eq!(r2, Error(nom::ErrorKind::TakeTill1));
/// # }
/// ```
#[macro_export]
macro_rules! take_till1 (
($input:expr, $submac:ident!( $($args:tt)* )) => (
Expand Down

0 comments on commit c4c045b

Please sign in to comment.