Skip to content

Commit

Permalink
Fix: Path internal representation and conversions (rust-lang#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spoonbender authored Oct 17, 2022
1 parent 93832b5 commit 0867e6a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/std_misc/path.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ between `Path` and `PathBuf` is similar to that of `str` and `String`:
a `PathBuf` can be mutated in-place, and can be dereferenced to a `Path`.

Note that a `Path` is *not* internally represented as an UTF-8 string, but
instead is stored as a vector of bytes (`Vec<u8>`). Therefore, converting a
`Path` to a `&str` is *not* free and may fail (an `Option` is returned).
instead is stored as an `OsString`. Therefore, converting a `Path` to a `&str`
is *not* free and may fail (an `Option` is returned). However, a `Path` can be
freely converted to an `OsString` or `&OsStr` using `into_os_string` and
`as_os_str`, respectively.

```rust,editable
use std::path::Path;
Expand Down

0 comments on commit 0867e6a

Please sign in to comment.