Skip to content

Commit

Permalink
Replace a use of chain with tuple! and try_parse!
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Feb 8, 2016
1 parent 685c32e commit 575518e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tests/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ use nom::{IResult,not_line_ending, space, alphanumeric, multispace};
use std::str;
use std::collections::HashMap;

named!(category <&[u8], &str>,
chain!(
tag!("[") ~
name: map_res!(
take_until!("]"),
str::from_utf8) ~
tag!("]") ~
multispace? ,
||{ name }
)
);
fn category(input: &[u8]) -> IResult<&[u8], &str> {
let (i, (_, name, _, _)) = try_parse!(input,
tuple!(
tag!("["),
map_res!(
take_until!("]"),
str::from_utf8
),
tag!("]"),
opt!(multispace)
)
);

return IResult::Done(i, name)
}

named!(key_value <&[u8],(&str,&str)>,
chain!(
Expand Down

0 comments on commit 575518e

Please sign in to comment.