Created
January 4, 2025 03:03
-
-
Save rob-p/f46ead85fa9a66be2bb27c6d46264a4e to your computer and use it in GitHub Desktop.
use memchr
This file contains 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 create_record(line: &str) -> Record { | |
let finder = memchr::memmem::Finder::new("bc"); | |
let mut iter = line.split('\t').peekable(); | |
let name = iter.peek().unwrap().to_string(); | |
let count = iter | |
.filter(|s| finder.find(s[1..4].as_bytes()).is_some()) | |
.count(); | |
Record::new(name, count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment