Skip to content

Commit

Permalink
Rollup merge of rust-lang#92513 - Xuanwo:path-buf, r=dtolnay
Browse files Browse the repository at this point in the history
std: Implement try_reserve and try_reserve_exact on PathBuf

Part of rust-lang#91789

Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
matthiaskrgr authored Jan 24, 2022
2 parents ef119d7 + edae82e commit b92a1e9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ mod tests;

use crate::borrow::{Borrow, Cow};
use crate::cmp;
use crate::collections::TryReserveError;
use crate::error::Error;
use crate::fmt;
use crate::fs;
Expand Down Expand Up @@ -1512,6 +1513,15 @@ impl PathBuf {
self.inner.reserve(additional)
}

/// Invokes [`try_reserve`] on the underlying instance of [`OsString`].
///
/// [`try_reserve`]: OsString::try_reserve
#[unstable(feature = "try_reserve_2", issue = "91789")]
#[inline]
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
self.inner.try_reserve(additional)
}

/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`].
///
/// [`reserve_exact`]: OsString::reserve_exact
Expand All @@ -1521,6 +1531,15 @@ impl PathBuf {
self.inner.reserve_exact(additional)
}

/// Invokes [`try_reserve_exact`] on the underlying instance of [`OsString`].
///
/// [`try_reserve_exact`]: OsString::try_reserve_exact
#[unstable(feature = "try_reserve_2", issue = "91789")]
#[inline]
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
self.inner.try_reserve_exact(additional)
}

/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`].
///
/// [`shrink_to_fit`]: OsString::shrink_to_fit
Expand Down

0 comments on commit b92a1e9

Please sign in to comment.