Skip to content

Commit a1e9c7f

Browse files
committed
OsStr: clarify len() method documentation
1 parent 0591ff7 commit a1e9c7f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/libstd/ffi/os_str.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,14 +590,19 @@ impl OsStr {
590590

591591
/// Returns the length of this `OsStr`.
592592
///
593-
/// Note that this does **not** return the number of bytes in this string
594-
/// as, for example, OS strings on Windows are encoded as a list of [`u16`]
595-
/// rather than a list of bytes. This number is simply useful for passing to
596-
/// other methods like [`OsString::with_capacity`] to avoid reallocations.
593+
/// Note that this does **not** return the number of bytes in the string in
594+
/// OS string form.
597595
///
598-
/// See `OsStr` introduction for more information about encoding.
596+
/// The length returned is that of the underlying storage used by `OsStr`;
597+
/// As discussed in the [`OsString`] introduction, [`OsString`] and `OsStr`
598+
/// store strings in a form best suited for cheap inter-conversion between
599+
/// native-platform and Rust string forms, which may differ significantly
600+
/// from both of them, including in storage size and encoding.
599601
///
600-
/// [`u16`]: ../primitive.u16.html
602+
/// This number is simply useful for passing to other methods, like
603+
/// [`OsString::with_capacity`] to avoid reallocations.
604+
///
605+
/// [`OsString`]: struct.OsString.html
601606
/// [`OsString::with_capacity`]: struct.OsString.html#method.with_capacity
602607
///
603608
/// # Examples

0 commit comments

Comments
 (0)