about summary refs log tree commit diff
path: root/src/libstd/sys/unix
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-02-20 18:35:16 +0000
committerbors <bors@rust-lang.org>2016-02-20 18:35:16 +0000
commit788a21edd4fab6c0035d91f1ac9f5896f065e06f (patch)
treefe6ad30da3ba5d35be27ed58ae3612195e65e89b /src/libstd/sys/unix
parent2d14b39204e648a219a17335e712c3fb14666a07 (diff)
parent2338d7419743f876135f723d1823dde16bdb7fdf (diff)
downloadrust-788a21edd4fab6c0035d91f1ac9f5896f065e06f.tar.gz
rust-788a21edd4fab6c0035d91f1ac9f5896f065e06f.zip
Auto merge of #31608 - frewsxcv:osstring-simple-functions, r=alexcrichton
https://github.com/rust-lang/rust/issues/29453
Diffstat (limited to 'src/libstd/sys/unix')
-rw-r--r--src/libstd/sys/unix/os_str.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs
index 0524df218a1..d5eea5d1f3b 100644
--- a/src/libstd/sys/unix/os_str.rs
+++ b/src/libstd/sys/unix/os_str.rs
@@ -17,6 +17,7 @@ use vec::Vec;
 use str;
 use string::String;
 use mem;
+use sys_common::{AsInner, IntoInner};
 
 #[derive(Clone, Hash)]
 pub struct Buf {
@@ -39,11 +40,51 @@ impl Debug for Buf {
     }
 }
 
+impl IntoInner<Vec<u8>> for Buf {
+    fn into_inner(self) -> Vec<u8> {
+        self.inner
+    }
+}
+
+impl AsInner<[u8]> for Buf {
+    fn as_inner(&self) -> &[u8] {
+        &self.inner
+    }
+}
+
+
 impl Buf {
     pub fn from_string(s: String) -> Buf {
         Buf { inner: s.into_bytes() }
     }
 
+    #[inline]
+    pub fn with_capacity(capacity: usize) -> Buf {
+        Buf {
+            inner: Vec::with_capacity(capacity)
+        }
+    }
+
+    #[inline]
+    pub fn clear(&mut self) {
+        self.inner.clear()
+    }
+
+    #[inline]
+    pub fn capacity(&self) -> usize {
+        self.inner.capacity()
+    }
+
+    #[inline]
+    pub fn reserve(&mut self, additional: usize) {
+        self.inner.reserve(additional)
+    }
+
+    #[inline]
+    pub fn reserve_exact(&mut self, additional: usize) {
+        self.inner.reserve_exact(additional)
+    }
+
     pub fn as_slice(&self) -> &Slice {
         unsafe { mem::transmute(&*self.inner) }
     }