Skip to content

Instantly share code, notes, and snippets.

@rob-p
Created January 4, 2025 03:03
Show Gist options
  • Save rob-p/f46ead85fa9a66be2bb27c6d46264a4e to your computer and use it in GitHub Desktop.
Save rob-p/f46ead85fa9a66be2bb27c6d46264a4e to your computer and use it in GitHub Desktop.
use memchr
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