[−][src]Function string_parser::string_parser
pub fn string_parser(
path: &str,
text: &str,
end_filter: fn(_: Vec<char>) -> bool,
callback: fn(_: String)
) -> Result<(), Error>
Arguments
path
- the path to the file to search fromtext
- the text to searchend_filter
- the function called at each character to check if we're still within the token. Sould return true when out of the token.callback
- the function called when the text is exited. take the inside of the token as argument
Examples
./text being "...'foo'..."
extern crate string_parser; use string_parser::string_parser; fn end_filter(c : Vec<char>) -> bool{ if c.last().unwrap()== &'\'' { return true; } else { return false; } } fn callback(s : String){ assert_eq!(String::from("foo"), s); } string_parser("./text", "'", end_filter, callback).unwrap();