Rollup merge of #40410 - clarcharr:os_string_shrink_to_fit, r=alexcrichton
OsString::shrink_to_fit. Considering how the other capacity-related methods are there, I found it odd that this one wasn't included. Will create a tracking issue once I get an OK on this.
This commit is contained in:
commit
f4b4e097a6
|
@ -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> {
|
||||
|
|
|
@ -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) }
|
||||
}
|
||||
|
|
|
@ -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) }
|
||||
}
|
||||
|
|
|
@ -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()) }
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue