Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![feature(core_intrinsics)]
- use std::intrinsics::unlikely;
- pub fn with_unlikely(slice: &[u8], pos: usize) -> &[u8] {
- if unsafe { unlikely(pos >= slice.len()) } {
- return &[]
- }
- &slice[pos..]
- }
- pub fn with_get_unwrap_or(slice: &[u8], pos: usize) -> &[u8] {
- slice.get(pos..).unwrap_or(&[])
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement