Skip to content

Commit 2774466

Browse files
committed
Improve documentation
1 parent fa14184 commit 2774466

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OsStr Bytes
22

3-
This crate allows interacting with the data stored internally by [`OsStr`] and
3+
This crate allows interacting with the data stored by [`OsStr`] and
44
[`OsString`], without resorting to panics or corruption for invalid UTF-8.
55
Thus, methods can be used that are already defined on [`[u8]`][slice] and
66
[`Vec<u8>`].

src/lib.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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>`].
55
//!
66
//! Typically, the only way to losslessly construct [`OsStr`] or [`OsString`]
77
//! from a byte sequence is to use `OsStr::new(str::from_utf8(bytes)?)`, which
@@ -36,9 +36,12 @@
3636
//! Additionally, concatenation may yield unexpected results without a UTF-8
3737
//! separator. If two platform strings need to be concatenated, the only safe
3838
//! 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.
4245
//!
4346
//! # User Input
4447
//!
@@ -138,6 +141,8 @@
138141
//! [`ByteVec::into_os_string`]: https://docs.rs/bstr/0.2.12/bstr/trait.ByteVec.html#method.into_os_string
139142
//! [memchr complexity]: RawOsStr#complexity
140143
//! [memchr]: https://crates.io/crates/memchr
144+
//! [`OsStrExt`]: ::std::os::unix::ffi::OsStrExt
145+
//! [`OsStringExt`]: ::std::os::unix::ffi::OsStringExt
141146
//! [sealed]: https://rust-lang.github.io/api-guidelines/future-proofing.html#c-sealed
142147
//! [print\_bytes]: https://crates.io/crates/print_bytes
143148

0 commit comments

Comments
 (0)