diff options
| author | David Tolnay <dtolnay@gmail.com> | 2021-12-30 12:45:02 -0800 |
|---|---|---|
| committer | David Tolnay <dtolnay@gmail.com> | 2021-12-30 12:45:02 -0800 |
| commit | d29941e7249c73327317b0c3ebaa98ae3228bcfc (patch) | |
| tree | 77d445e9daaf7659d63e0db1c5153603f1a91fd1 | |
| parent | 1f62c24d5a11fcbc3b9d489bcac9492daf7fb82a (diff) | |
| download | rust-d29941e7249c73327317b0c3ebaa98ae3228bcfc.tar.gz rust-d29941e7249c73327317b0c3ebaa98ae3228bcfc.zip | |
Remove needless allocation from example code of OsString
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 8424e565569..982ad189878 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -281,14 +281,14 @@ impl OsString { /// /// ``` /// #![feature(try_reserve_2)] - /// use std::ffi::OsString; + /// use std::ffi::{OsStr, OsString}; /// use std::collections::TryReserveError; /// /// fn process_data(data: &str) -> Result<OsString, TryReserveError> { /// let mut s = OsString::new(); /// /// // Pre-reserve the memory, exiting if we can't - /// s.try_reserve(OsString::from(data).len())?; + /// s.try_reserve(OsStr::new(data).len())?; /// /// // Now we know this can't OOM in the middle of our complex work /// s.push(data); @@ -349,14 +349,14 @@ impl OsString { /// /// ``` /// #![feature(try_reserve_2)] - /// use std::ffi::OsString; + /// use std::ffi::{OsStr, OsString}; /// use std::collections::TryReserveError; /// /// fn process_data(data: &str) -> Result<OsString, TryReserveError> { /// let mut s = OsString::new(); /// /// // Pre-reserve the memory, exiting if we can't - /// s.try_reserve_exact(OsString::from(data).len())?; + /// s.try_reserve_exact(OsStr::new(data).len())?; /// /// // Now we know this can't OOM in the middle of our complex work /// s.push(data); |
