Sha256: c5e998dcdb9fcbafacdeee7d590fd55423576ee8f929fcae0635f04a7c1b7fca

Contents?: true

Size: 399 Bytes

Versions: 2

Compression:

Stored size: 399 Bytes

Contents

use libc::c_char;
use std::ffi::{CStr};
use std::str;
use std::path::MAIN_SEPARATOR;


#[no_mangle]
pub extern fn is_absolute(string: *const c_char) -> bool {
  let c_str = unsafe {
    assert!(!string.is_null());

    CStr::from_ptr(string)
  };

  let r_str = str::from_utf8(c_str.to_bytes()).unwrap_or("");

  r_str.chars().next().unwrap_or("muffins".chars().next().unwrap()) == MAIN_SEPARATOR
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
faster_path-0.1.7 src/is_absolute.rs
faster_path-0.1.6 src/is_absolute.rs