You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BREAKING:to_slash and to_slash_lossy return Cow<'_, str> instead of String. Now heap allocation hapnens only when path separator is replaced. On Unix-like OS, almost all heap allocations can be removed by this change. Migrating from 0.1 to 0.2 is quite easy by adding Cow::into_owned call. If &str is sufficient for your use case, Cow::as_ref is better to avoid heap allocation. (#9)
BREAKING: Fix inconsistency on Windows and on Unix-like OS in terms of trailing slash in path. Now a trailing slash in path is always preserved. (#10)
// 0.1#[cfg(target_os = "windows")]assert_eq!(Path::new(r"\a\b\").to_slash_lossy(),"/a/b");// Trailing slash is removed#[cfg(not(target_os = "windows"))]assert_eq!(Path::new("/a/b/").to_slash_lossy(),"/a/b/");// Trailing slash is preserved// 0.2#[cfg(target_os = "windows")]assert_eq!(Path::new(r"\a\b\").to_slash_lossy(),"/a/b/");// Trailing slash is preserved#[cfg(not(target_os = "windows"))]assert_eq!(Path::new("/a/b/").to_slash_lossy(),"/a/b/");// Trailing slash is preserved
New API path_slash::CowExt is added to extend Cow<'_, Path>. Its methods convert slash paths into Cow<'_, Path>. It is useful to avoid heap allocations as much as possible compared with PathBufExt. See the API document for more details. (#9)
use path_slash::CowExtas _;let p = Cow::from_slash("foo/bar/piyo.txt");// Heap allocation only happens on Windows#[cfg(target_os = "windows")]assert_eq!(p,Cow::Owned(PathBuf::from(r"foo\bar\piyo.txt")));#[cfg(not(target_os = "windows"))]assert_eq!(p,Cow::Borrowed(Path::new("foo/bar/piyo.txt")));
All methods added by importing CowExt are as follows: