From 2338d7419743f876135f723d1823dde16bdb7fdf Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 12 Feb 2016 12:21:57 -0500 Subject: Add Capacity/length methods for OsString. https://github.com/rust-lang/rust/issues/29453 --- src/libstd/sys/common/wtf8.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/libstd/sys/common') diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index bc997af3a27..68ba2fe20b4 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -178,6 +178,10 @@ impl Wtf8Buf { Wtf8Buf { bytes: <[_]>::to_vec(str.as_bytes()) } } + pub fn clear(&mut self) { + self.bytes.clear() + } + /// Creates a WTF-8 string from a potentially ill-formed UTF-16 slice of 16-bit code units. /// /// This is lossless: calling `.encode_wide()` on the resulting string @@ -234,6 +238,11 @@ impl Wtf8Buf { self.bytes.reserve(additional) } + #[inline] + pub fn reserve_exact(&mut self, additional: usize) { + self.bytes.reserve_exact(additional) + } + /// Returns the number of bytes that this string buffer can hold without reallocating. #[inline] pub fn capacity(&self) -> usize { @@ -443,6 +452,11 @@ impl Wtf8 { self.bytes.len() } + #[inline] + pub fn is_empty(&self) -> bool { + self.bytes.is_empty() + } + /// Returns the code point at `position` if it is in the ASCII range, /// or `b'\xFF' otherwise. /// -- cgit 1.4.1-3-g733a5