diff options
| author | FenrirWolf <[email protected]> | 2018-04-21 16:39:03 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-04-21 16:39:03 -0600 |
| commit | 159b5b9e62ce074bbbd1900137670a9f5426a8bd (patch) | |
| tree | 4fecd0ca00b754c494e96b13e9837db48de93109 /ctr-std/src/ffi/os_str.rs | |
| parent | Move more implementation details to `imp` module (diff) | |
| parent | Update for Rust nightly 2018-04-19 (diff) | |
| download | archived-ctru-rs-159b5b9e62ce074bbbd1900137670a9f5426a8bd.tar.xz archived-ctru-rs-159b5b9e62ce074bbbd1900137670a9f5426a8bd.zip | |
Merge pull request #64 from FenrirWolf/nightly-update
Update for Rust nightly 2018-04-19
Diffstat (limited to 'ctr-std/src/ffi/os_str.rs')
| -rw-r--r-- | ctr-std/src/ffi/os_str.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ctr-std/src/ffi/os_str.rs b/ctr-std/src/ffi/os_str.rs index 3959e85..7520121 100644 --- a/ctr-std/src/ffi/os_str.rs +++ b/ctr-std/src/ffi/os_str.rs @@ -295,6 +295,36 @@ impl OsString { self.inner.shrink_to_fit() } + /// Shrinks the capacity of the `OsString` with a lower bound. + /// + /// The capacity will remain at least as large as both the length + /// and the supplied value. + /// + /// Panics if the current capacity is smaller than the supplied + /// minimum capacity. + /// + /// # Examples + /// + /// ``` + /// #![feature(shrink_to)] + /// use std::ffi::OsString; + /// + /// let mut s = OsString::from("foo"); + /// + /// s.reserve(100); + /// assert!(s.capacity() >= 100); + /// + /// s.shrink_to(10); + /// assert!(s.capacity() >= 10); + /// s.shrink_to(0); + /// assert!(s.capacity() >= 3); + /// ``` + #[inline] + #[unstable(feature = "shrink_to", reason = "new API", issue="0")] + pub fn shrink_to(&mut self, min_capacity: usize) { + self.inner.shrink_to(min_capacity) + } + /// Converts this `OsString` into a boxed [`OsStr`]. /// /// [`OsStr`]: struct.OsStr.html |