Sha256: 86a1cf92b6fa67b0210d5027878b6a75e1c85dc0b0e42245612c78e6f98d41c9

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

extern crate memchr;

use self::memchr::{memchr, memrchr};
use memrnchr::memrnchr;
use std::path::MAIN_SEPARATOR;
use std::str;

pub const SEP: u8 = MAIN_SEPARATOR as u8;
lazy_static! {
  pub static ref SEP_STR: &'static str = str::from_utf8(&[SEP]).unwrap();
}

// Returns the byte offset of the last byte that equals MAIN_SEPARATOR.
#[inline(always)]
pub fn find_last_dot_pos(bytes: &[u8]) -> Option<usize> {
  memrchr(b'.', bytes)
}

// Returns the byte offset of the last byte that equals MAIN_SEPARATOR.
#[inline(always)]
pub fn find_last_sep_pos(bytes: &[u8]) -> Option<usize> {
  memrchr(SEP, bytes)
}

// Returns the byte offset of the last byte that is not MAIN_SEPARATOR.
#[inline(always)]
pub fn find_last_non_sep_pos(bytes: &[u8]) -> Option<usize> {
  memrnchr(SEP, bytes)
}

// Whether the given byte sequence contains a MAIN_SEPARATOR.
#[inline(always)]
pub fn contains_sep(bytes: &[u8]) -> bool {
  memchr(SEP, bytes) != None
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faster_path-0.3.8 src/path_parsing.rs