Skip to content

Commit d269f8d

Browse files
committed
Merge branch 'os_string_shrink_to_fit' of https://github.com/clarcharr/rust into rollup
2 parents f970a07 + 83814fd commit d269f8d

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

src/libstd/ffi/os_str.rs

+6
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ impl OsString {
205205
self.inner.reserve_exact(additional)
206206
}
207207

208+
/// Shrinks the capacity of the `OsString` to match its length.
209+
#[unstable(feature = "osstring_shrink_to_fit", issue = "40421")]
210+
pub fn shrink_to_fit(&mut self) {
211+
self.inner.shrink_to_fit()
212+
}
213+
208214
/// Converts this `OsString` into a boxed `OsStr`.
209215
#[unstable(feature = "into_boxed_os_str", issue = "0")]
210216
pub fn into_boxed_os_str(self) -> Box<OsStr> {

src/libstd/sys/redox/os_str.rs

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ impl Buf {
8383
self.inner.reserve_exact(additional)
8484
}
8585

86+
#[inline]
87+
pub fn shrink_to_fit(&mut self) {
88+
self.inner.shrink_to_fit()
89+
}
90+
8691
pub fn as_slice(&self) -> &Slice {
8792
unsafe { mem::transmute(&*self.inner) }
8893
}

src/libstd/sys/unix/os_str.rs

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ impl Buf {
8383
self.inner.reserve_exact(additional)
8484
}
8585

86+
#[inline]
87+
pub fn shrink_to_fit(&mut self) {
88+
self.inner.shrink_to_fit()
89+
}
90+
8691
pub fn as_slice(&self) -> &Slice {
8792
unsafe { mem::transmute(&*self.inner) }
8893
}

src/libstd/sys/windows/os_str.rs

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ impl Buf {
8989
self.inner.reserve_exact(additional)
9090
}
9191

92+
pub fn shrink_to_fit(&mut self) {
93+
self.inner.shrink_to_fit()
94+
}
95+
9296
#[inline]
9397
pub fn into_box(self) -> Box<Slice> {
9498
unsafe { mem::transmute(self.inner.into_box()) }

src/libstd/sys_common/wtf8.rs

+5
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ impl Wtf8Buf {
236236
self.bytes.reserve_exact(additional)
237237
}
238238

239+
#[inline]
240+
pub fn shrink_to_fit(&mut self) {
241+
self.bytes.shrink_to_fit()
242+
}
243+
239244
/// Returns the number of bytes that this string buffer can hold without reallocating.
240245
#[inline]
241246
pub fn capacity(&self) -> usize {

0 commit comments

Comments
 (0)