Created
December 5, 2019 20:55
-
-
Save jamesmcm/93a51c164692fb8ba837710ea04649c7 to your computer and use it in GitHub Desktop.
split_with_matches_broken.rs
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 characters
| fn split_with_matches<F>(s: &str, f: F) -> Vec<&str> where | |
| F: Fn(char) -> bool { | |
| let mut out: Vec<&str> = vec![]; | |
| let mut curstring: String = String::new(); | |
| for c in s.chars() { | |
| if f(c) { | |
| out.push(&curstring); | |
| out.push(&c.to_string()); | |
| } else { | |
| curstring.push(c); | |
| } | |
| } | |
| out | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment