fix: import from private module

This commit is contained in:
alan910127 2024-11-03 01:00:00 +08:00
parent cb217e5e7f
commit f5ed58c97a

View file

@ -91,9 +91,11 @@ fn path_to_os_str(path: &Path, _separator: PathSeparator) -> Cow<'_, OsStr> {
#[cfg(windows)] #[cfg(windows)]
fn path_to_os_str(path: &Path, separator: PathSeparator) -> Cow<'_, OsStr> { fn path_to_os_str(path: &Path, separator: PathSeparator) -> Cow<'_, OsStr> {
use yazi_shared::fs::backslash_to_slash;
match separator { match separator {
PathSeparator::Auto => Cow::Borrowed(path.as_os_str()), PathSeparator::Auto => Cow::Borrowed(path.as_os_str()),
PathSeparator::Unix => match yazi_shared::fs::path::backslash_to_slash(path) { PathSeparator::Unix => match backslash_to_slash(path) {
Cow::Borrowed(path) => Cow::Borrowed(path.as_os_str()), Cow::Borrowed(path) => Cow::Borrowed(path.as_os_str()),
Cow::Owned(path) => Cow::Owned(OsString::from(path)), Cow::Owned(path) => Cow::Owned(OsString::from(path)),
}, },
@ -106,7 +108,7 @@ mod tests {
use super::*; use super::*;
#[cfg(target_os = "windows")] #[cfg(windows)]
#[test] #[test]
fn test_path_to_os_str_windows_auto() { fn test_path_to_os_str_windows_auto() {
let path = PathBuf::from("C:\\Users\\JohnDoe\\Downloads\\image.png"); let path = PathBuf::from("C:\\Users\\JohnDoe\\Downloads\\image.png");
@ -117,7 +119,7 @@ mod tests {
); );
} }
#[cfg(target_os = "windows")] #[cfg(windows)]
#[test] #[test]
fn test_path_to_os_str_windows_unix() { fn test_path_to_os_str_windows_unix() {
let path = PathBuf::from("C:\\Users\\JohnDoe\\Downloads\\image.png"); let path = PathBuf::from("C:\\Users\\JohnDoe\\Downloads\\image.png");
@ -128,7 +130,7 @@ mod tests {
); );
} }
#[cfg(not(target_os = "windows"))] #[cfg(unix)]
#[test] #[test]
fn test_path_to_os_str_unix_auto() { fn test_path_to_os_str_unix_auto() {
let path = PathBuf::from("/home/johndoe/Downloads/image.png"); let path = PathBuf::from("/home/johndoe/Downloads/image.png");
@ -139,7 +141,7 @@ mod tests {
); );
} }
#[cfg(not(target_os = "windows"))] #[cfg(unix)]
#[test] #[test]
fn test_path_to_os_str_unix_unix() { fn test_path_to_os_str_unix_unix() {
let path = PathBuf::from("/home/johndoe/Downloads/image.png"); let path = PathBuf::from("/home/johndoe/Downloads/image.png");