mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 04:55:22 +03:00
OsStr: Document that it's not NUL terminated
I somehow got confused into thinking this was the case, but it's definitely not. Let's help the common case of people who have an `OsStr` and need to call e.g. Unix APIs.
This commit is contained in:
@@ -34,7 +34,9 @@
|
||||
///
|
||||
/// `OsString` and [`OsStr`] bridge this gap by simultaneously representing Rust
|
||||
/// and platform-native string values, and in particular allowing a Rust string
|
||||
/// to be converted into an "OS" string with no cost if possible.
|
||||
/// to be converted into an "OS" string with no cost if possible. A consequence
|
||||
/// of this is that `OsString` instances are *not* `NUL` terminated; in order
|
||||
/// to pass to e.g. Unix system call, you should create a [`CStr`].
|
||||
///
|
||||
/// `OsString` is to [`&OsStr`] as [`String`] is to [`&str`]: the former
|
||||
/// in each pair are owned strings; the latter are borrowed
|
||||
@@ -65,6 +67,7 @@
|
||||
///
|
||||
/// [`OsStr`]: struct.OsStr.html
|
||||
/// [`&OsStr`]: struct.OsStr.html
|
||||
/// [`CStr`]: struct.CStr.html
|
||||
/// [`From`]: ../convert/trait.From.html
|
||||
/// [`String`]: ../string/struct.String.html
|
||||
/// [`&str`]: ../primitive.str.html
|
||||
|
||||
Reference in New Issue
Block a user