diff --git a/src/os_string_builder.rs b/src/os_string_builder.rs index a00f3a1..182b2df 100644 --- a/src/os_string_builder.rs +++ b/src/os_string_builder.rs @@ -2,7 +2,6 @@ use std::ffi::{OsStr, OsString}; use std::fmt::{Debug, Formatter}; use std::hash::{Hash, Hasher}; use std::ops::{Add, AddAssign}; -use std::os::unix::ffi::OsStrExt; #[derive(Clone, Default, Eq)] pub struct OsStringBuilder { @@ -75,22 +74,6 @@ impl Hash for OsStringBuilder { } } -pub fn ensure_trailing_slash(path: impl AsRef) -> OsString { - let mut str = path.as_ref().to_os_string(); - if !str.as_bytes().ends_with(b"/") { - str.push("/") - } - str -} - -#[macro_export] -macro_rules! dir { - ($path:expr) => {{ - use $crate::os_string_builder::ensure_trailing_slash; - ensure_trailing_slash($path) - }}; -} - #[macro_export] macro_rules! osf { () => {{ @@ -116,6 +99,6 @@ mod test { let foo = PathBuf::from("foo"); let bar = PathBuf::from("bar"); - assert_eq!(osf!("cd ") + dir!(foo) + dir!(bar), "cd foo/bar/"); + assert_eq!(osf!("cd ") + foo.join(&bar), "cd foo/bar"); } }