faster_path 0.0.2

Alternative to Pathname
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use libc::c_char;
use std::ffi::{CStr};
use std::path::MAIN_SEPARATOR;


#[no_mangle]
pub extern fn is_absolute(path: *const c_char) -> bool {
  if path.is_null() {
    return false;
  }
  let r_str = unsafe { CStr::from_ptr(path) }.to_str().unwrap();

  match r_str.chars().next() {
    Some(c) => c == MAIN_SEPARATOR,
    None => false
  }
}