|
1 |
| -//! This crate allows interacting with the data stored internally by [`OsStr`] |
2 |
| -//! and [`OsString`], without resorting to panics or corruption for invalid |
3 |
| -//! UTF-8. Thus, methods can be used that are already defined on |
4 |
| -//! [`[u8]`][slice] and [`Vec<u8>`]. |
| 1 | +//! This crate allows interacting with the data stored by [`OsStr`] and |
| 2 | +//! [`OsString`], without resorting to panics or corruption for invalid UTF-8. |
| 3 | +//! Thus, methods can be used that are already defined on [`[u8]`][slice] and |
| 4 | +//! [`Vec<u8>`]. |
5 | 5 | //!
|
6 | 6 | //! Typically, the only way to losslessly construct [`OsStr`] or [`OsString`]
|
7 | 7 | //! from a byte sequence is to use `OsStr::new(str::from_utf8(bytes)?)`, which
|
|
36 | 36 | //! Additionally, concatenation may yield unexpected results without a UTF-8
|
37 | 37 | //! separator. If two platform strings need to be concatenated, the only safe
|
38 | 38 | //! way to do so is using [`OsString::push`]. This limitation also makes it
|
39 |
| -//! undesirable to use the bytes in interchange unless absolutely necessary. If |
40 |
| -//! the strings need to be written as output, crate [print\_bytes] can do so |
41 |
| -//! more safely than directly writing the bytes. |
| 39 | +//! undesirable to use the bytes in interchange. |
| 40 | +//! |
| 41 | +//! Since this encoding can change between versions and platforms, it should |
| 42 | +//! not be used for storage. The standard library provides implementations of |
| 43 | +//! [`OsStrExt`] and [`OsStringExt`] for various platforms, which should be |
| 44 | +//! preferred for that use case. |
42 | 45 | //!
|
43 | 46 | //! # User Input
|
44 | 47 | //!
|
|
138 | 141 | //! [`ByteVec::into_os_string`]: https://docs.rs/bstr/0.2.12/bstr/trait.ByteVec.html#method.into_os_string
|
139 | 142 | //! [memchr complexity]: RawOsStr#complexity
|
140 | 143 | //! [memchr]: https://crates.io/crates/memchr
|
| 144 | +//! [`OsStrExt`]: ::std::os::unix::ffi::OsStrExt |
| 145 | +//! [`OsStringExt`]: ::std::os::unix::ffi::OsStringExt |
141 | 146 | //! [sealed]: https://rust-lang.github.io/api-guidelines/future-proofing.html#c-sealed
|
142 | 147 | //! [print\_bytes]: https://crates.io/crates/print_bytes
|
143 | 148 |
|
|
0 commit comments