Skip to content

Commit 6e01d3d

Browse files
committed
Update docs
1 parent 9a1c795 commit 6e01d3d

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ across platforms.
2727
Add `relative-path` to your `Cargo.toml`:
2828

2929
```toml
30-
relative-path = "1.8.1"
30+
relative-path = "1.9.0"
3131
```
3232

3333
Start using relative paths:
@@ -230,13 +230,16 @@ not be used as legal paths on all platforms.
230230
* Windows has a number of [reserved characters and names][windows-reserved]
231231
(like `CON`, `PRN`, and `AUX`) which cannot legally be part of a
232232
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.
233236

234237
A relative path that *accidentally* contains a platform-specific components
235238
will largely result in a nonsensical paths being generated in the hope that
236239
they will fail fast during development and testing.
237240

238241
```rust
239-
use relative_path::RelativePath;
242+
use relative_path::{RelativePath, PathExt};
240243
use std::path::Path;
241244

242245
if cfg!(windows) {
@@ -252,6 +255,11 @@ if cfg!(unix) {
252255
RelativePath::new("/bar/baz").to_path("foo")
253256
);
254257
}
258+
259+
assert_eq!(
260+
Path::new("foo").relative_to("bar")?,
261+
RelativePath::new("../foo"),
262+
);
255263
```
256264

257265
[`None`]: https://doc.rust-lang.org/std/option/enum.Option.html
@@ -264,3 +272,4 @@ if cfg!(unix) {
264272
[`to_logical_path`]: https://docs.rs/relative-path/1/relative_path/struct.RelativePath.html#method.to_logical_path
265273
[`to_path`]: https://docs.rs/relative-path/1/relative_path/struct.RelativePath.html#method.to_path
266274
[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

src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,13 @@
259259
//! Path::new("foo/bar/baz"),
260260
//! RelativePath::new("/bar/baz").to_path("foo")
261261
//! );
262-
//! assert_eq!(
263-
//! Path::new("foo").relative_to("bar").unwrap(),
264-
//! RelativePath::new("../foo"),
265-
//! );
266262
//! }
263+
//!
264+
//! assert_eq!(
265+
//! Path::new("foo").relative_to("bar")?,
266+
//! RelativePath::new("../foo"),
267+
//! );
268+
//! # Ok::<_, Box<dyn std::error::Error>>(())
267269
//! ```
268270
//!
269271
//! [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html

0 commit comments

Comments
 (0)