src/basename.rs in faster_path-0.1.5 vs src/basename.rs in faster_path-0.1.6
- old
+ new
@@ -1,5 +1,10 @@
+use std::path::MAIN_SEPARATOR;
+use libc::c_char;
+use std::ffi::{CStr,CString};
+use std::str;
+
#[allow(dead_code)]
fn rubyish_basename(string: &str, globish_string: &str) -> String {
let result = if globish_string == ".*" {
let base = string.rsplit_terminator(MAIN_SEPARATOR).nth(0).unwrap_or("");
let index = base.rfind(".");
@@ -46,10 +51,10 @@
assert_eq!(rubyish_basename("asdf/asdf.rb.swp", ".r*.sw*p") , "asdf.rb.swp");
assert_eq!(rubyish_basename("asdf/asdf.rb.swp", ".r*b.sw*p") , "asdf.rb.swp");
assert_eq!(rubyish_basename("asdf/asdf.rb.swp", "rb.swp") , "asdf.");
}
-//#[no_mangle]
+#[no_mangle]
pub extern fn basename(str_pth: *const c_char, comp_ext: *const c_char) -> *const c_char {
let c_str1 = unsafe {
assert!(!str_pth.is_null());
CStr::from_ptr(str_pth)
};