OsString::shrink_to_fit.

This commit is contained in:
Clar Charr 2017-03-10 00:23:54 -05:00
parent ec87925325
commit 83814fd8ab
5 changed files with 25 additions and 0 deletions

View File

@ -205,6 +205,12 @@ impl OsString {
self.inner.reserve_exact(additional)
}
/// Shrinks the capacity of the `OsString` to match its length.
#[unstable(feature = "osstring_shrink_to_fit", issue = "40421")]
pub fn shrink_to_fit(&mut self) {
self.inner.shrink_to_fit()
}
/// Converts this `OsString` into a boxed `OsStr`.
#[unstable(feature = "into_boxed_os_str", issue = "0")]
pub fn into_boxed_os_str(self) -> Box<OsStr> {

View File

@ -83,6 +83,11 @@ impl Buf {
self.inner.reserve_exact(additional)
}
#[inline]
pub fn shrink_to_fit(&mut self) {
self.inner.shrink_to_fit()
}
pub fn as_slice(&self) -> &Slice {
unsafe { mem::transmute(&*self.inner) }
}

View File

@ -83,6 +83,11 @@ impl Buf {
self.inner.reserve_exact(additional)
}
#[inline]
pub fn shrink_to_fit(&mut self) {
self.inner.shrink_to_fit()
}
pub fn as_slice(&self) -> &Slice {
unsafe { mem::transmute(&*self.inner) }
}

View File

@ -89,6 +89,10 @@ impl Buf {
self.inner.reserve_exact(additional)
}
pub fn shrink_to_fit(&mut self) {
self.inner.shrink_to_fit()
}
#[inline]
pub fn into_box(self) -> Box<Slice> {
unsafe { mem::transmute(self.inner.into_box()) }

View File

@ -236,6 +236,11 @@ impl Wtf8Buf {
self.bytes.reserve_exact(additional)
}
#[inline]
pub fn shrink_to_fit(&mut self) {
self.bytes.shrink_to_fit()
}
/// Returns the number of bytes that this string buffer can hold without reallocating.
#[inline]
pub fn capacity(&self) -> usize {