@@ -27,7 +27,7 @@ across platforms.
27
27
Add ` relative-path ` to your ` Cargo.toml ` :
28
28
29
29
``` toml
30
- relative-path = " 1.8.1 "
30
+ relative-path = " 1.9.0 "
31
31
```
32
32
33
33
Start using relative paths:
@@ -230,13 +230,16 @@ not be used as legal paths on all platforms.
230
230
* Windows has a number of [ reserved characters and names] [ windows-reserved ]
231
231
(like ` CON ` , ` PRN ` , and ` AUX ` ) which cannot legally be part of a
232
232
filesystem component.
233
+ * Windows paths are [ case-insensitive by default] [ windows-case ] . So,
234
+ ` Foo.txt ` and ` foo.txt ` are the same files on windows. But they are
235
+ considered different paths on most unix systems.
233
236
234
237
A relative path that * accidentally* contains a platform-specific components
235
238
will largely result in a nonsensical paths being generated in the hope that
236
239
they will fail fast during development and testing.
237
240
238
241
``` rust
239
- use relative_path :: RelativePath ;
242
+ use relative_path :: { RelativePath , PathExt } ;
240
243
use std :: path :: Path ;
241
244
242
245
if cfg! (windows ) {
@@ -252,6 +255,11 @@ if cfg!(unix) {
252
255
RelativePath :: new (" /bar/baz" ). to_path (" foo" )
253
256
);
254
257
}
258
+
259
+ assert_eq! (
260
+ Path :: new (" foo" ). relative_to (" bar" )? ,
261
+ RelativePath :: new (" ../foo" ),
262
+ );
255
263
```
256
264
257
265
[ `None` ] : https://doc.rust-lang.org/std/option/enum.Option.html
@@ -264,3 +272,4 @@ if cfg!(unix) {
264
272
[ `to_logical_path` ] : https://docs.rs/relative-path/1/relative_path/struct.RelativePath.html#method.to_logical_path
265
273
[ `to_path` ] : https://docs.rs/relative-path/1/relative_path/struct.RelativePath.html#method.to_path
266
274
[ windows-reserved ] : https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
275
+ [ windows-case ] : https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity
0 commit comments