Remove dead code from os_string_builder module

This commit is contained in:
Leonard Steppy 2024-12-13 12:51:59 +01:00
parent 435c87c958
commit 4f08fabd34

View File

@ -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<OsStr>) -> 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");
}
}