Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use memchr;
- fn main() {
- let input = "hello\nthere\nlol\ntrunc'd";
- let trunc = 3;
- let index = memchr::memchr_iter(b'\n', input.as_ref()).skip(trunc - 1).next().unwrap_or(input.len());
- println!("{}", &input[..index]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement