Skip to content

Commit 0591ff7

Browse files
committed
OsString: mention storage form in discussion
Helps users to understand capacity related values, which may surpise on Windows. Also is a step towards clarifying understanding of `OsStr`'s len() return value.
1 parent ee7bb94 commit 0591ff7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libstd/ffi/os_str.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ use sys_common::{AsInner, IntoInner, FromInner};
4242
/// in each pair are owned strings; the latter are borrowed
4343
/// references.
4444
///
45+
/// Note, `OsString` and `OsStr` internally do not necessarily hold strings in
46+
/// the form native to the platform; While on Unix, strings are stored as a
47+
/// sequence of 8-bit values, on Windows, where strings are 16-bit value based
48+
/// as just discussed, strings are also actually stored as a sequence of 8-bit
49+
/// values, encoded in a less-strict variant of UTF-8. This is useful to
50+
/// understand when handling capacity and length values.
51+
///
4552
/// # Creating an `OsString`
4653
///
4754
/// **From a Rust string**: `OsString` implements

0 commit comments

Comments
 (0)