Skip to content

Commit edae82e

Browse files
committed
std: Implement try_reserve and try_reserve_exact on PathBuf
Signed-off-by: Xuanwo <github@xuanwo.io>
1 parent b5da808 commit edae82e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

library/std/src/path.rs

+19
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ mod tests;
7272

7373
use crate::borrow::{Borrow, Cow};
7474
use crate::cmp;
75+
use crate::collections::TryReserveError;
7576
use crate::error::Error;
7677
use crate::fmt;
7778
use crate::fs;
@@ -1512,6 +1513,15 @@ impl PathBuf {
15121513
self.inner.reserve(additional)
15131514
}
15141515

1516+
/// Invokes [`try_reserve`] on the underlying instance of [`OsString`].
1517+
///
1518+
/// [`try_reserve`]: OsString::try_reserve
1519+
#[unstable(feature = "try_reserve_2", issue = "91789")]
1520+
#[inline]
1521+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
1522+
self.inner.try_reserve(additional)
1523+
}
1524+
15151525
/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`].
15161526
///
15171527
/// [`reserve_exact`]: OsString::reserve_exact
@@ -1521,6 +1531,15 @@ impl PathBuf {
15211531
self.inner.reserve_exact(additional)
15221532
}
15231533

1534+
/// Invokes [`try_reserve_exact`] on the underlying instance of [`OsString`].
1535+
///
1536+
/// [`try_reserve_exact`]: OsString::try_reserve_exact
1537+
#[unstable(feature = "try_reserve_2", issue = "91789")]
1538+
#[inline]
1539+
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
1540+
self.inner.try_reserve_exact(additional)
1541+
}
1542+
15241543
/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`].
15251544
///
15261545
/// [`shrink_to_fit`]: OsString::shrink_to_fit

0 commit comments

Comments
 (0)