[−][src]Function string_parser::string_parser
pub fn string_parser(
path: &str,
text: &str,
end_filter: impl Fn(Vec<char>) -> bool,
callback: impl FnMut(String)
) -> Result<(), Error>
Main function of the create
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; } } //can also use closures let callback = |s : String| { assert_eq!(String::from("foo"), s); }; string_parser("./text", "'", end_filter, callback).unwrap();