Created
December 16, 2016 23:55
-
-
Save anonymous/15d47d83be6c38665eb09fa88d4e7e3e to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #[macro_use] extern crate nom; use std::str; named!(split<&[u8], (&str, &str, &str, &str)>, do_parse!( v1: map_res!(take_until!(","), str::from_utf8) >> tag!(",") >> v2: map_res!(take_until!(","), str::from_utf8) >> tag!(",") >> v3: map_res!(take_until!(","), str::from_utf8) >> tag!(",") >> v4: map_res!(take_until!(","), str::from_utf8) >> (v1, v2, v3, v4) )); fn main() { let first_line = b"value1,value2,value3,value4"; println!("{:?}", split(&first_line[..])); }