diff options
| author | Xuanwo <github@xuanwo.io> | 2021-12-28 11:28:05 +0800 |
|---|---|---|
| committer | Xuanwo <github@xuanwo.io> | 2021-12-28 11:28:05 +0800 |
| commit | c40ac57efb88b308b869be2ec47da59aba3c842c (patch) | |
| tree | 23707be8198766bbe546c93cb8e593a6928cd5e6 /library/std/src/sys | |
| parent | 4ee34f355101db4d7a97455589c9dbc335d7a963 (diff) | |
| download | rust-c40ac57efb88b308b869be2ec47da59aba3c842c.tar.gz rust-c40ac57efb88b308b869be2ec47da59aba3c842c.zip | |
Add try_reserve for OsString
Signed-off-by: Xuanwo <github@xuanwo.io>
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/unix/os_str.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/os_str.rs b/library/std/src/sys/unix/os_str.rs index ae96d6b4df4..ccbc182240c 100644 --- a/library/std/src/sys/unix/os_str.rs +++ b/library/std/src/sys/unix/os_str.rs @@ -2,6 +2,7 @@ //! systems: just a `Vec<u8>`/`[u8]`. use crate::borrow::Cow; +use crate::collections::TryReserveError; use crate::fmt; use crate::fmt::Write; use crate::mem; @@ -113,11 +114,21 @@ impl Buf { } #[inline] + pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { + self.inner.try_reserve(additional) + } + + #[inline] pub fn reserve_exact(&mut self, additional: usize) { self.inner.reserve_exact(additional) } #[inline] + pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> { + self.inner.try_reserve_exact(additional) + } + + #[inline] pub fn shrink_to_fit(&mut self) { self.inner.shrink_to_fit() } |
