about summary refs log tree commit diff
path: root/src/libstd/ffi
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-04-09 09:17:34 +0000
committerbors <bors@rust-lang.org>2017-04-09 09:17:34 +0000
commitebb10a6131834e14f0685ef399b531444d631e9c (patch)
tree16a884068513cff9b9352a713c2aff7d74f3c15b /src/libstd/ffi
parentcff81da514068ea89e06d1a62357971d34094ea3 (diff)
parent68909b0ec0d8738a8f1a0bb7a80998a246943471 (diff)
downloadrust-ebb10a6131834e14f0685ef399b531444d631e9c.tar.gz
rust-ebb10a6131834e14f0685ef399b531444d631e9c.zip
Auto merge of #41095 - clarcharr:as_extras, r=alexcrichton
Add as_c_str

Again, tying up some consistencies with `CString`.
Diffstat (limited to 'src/libstd/ffi')
-rw-r--r--src/libstd/ffi/c_str.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index fc1b9a97632..29f977ecd8c 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -324,6 +324,12 @@ impl CString {
         &self.inner
     }
 
+    /// Extracts a `CStr` slice containing the entire string.
+    #[unstable(feature = "as_c_str", issue = "40380")]
+    pub fn as_c_str(&self) -> &CStr {
+        &*self
+    }
+
     /// Converts this `CString` into a boxed `CStr`.
     #[unstable(feature = "into_boxed_c_str", issue = "40380")]
     pub fn into_boxed_c_str(self) -> Box<CStr> {