about summary refs log tree commit diff
path: root/src/libstd/ffi
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-08-12 09:08:37 -0400
committerCorey Farwell <coreyf@rwell.org>2016-08-12 09:08:37 -0400
commit4e4d8baf7b99028a03280b90135117581c15d874 (patch)
tree94284023199e477a56d841c36f80a0b8fc396852 /src/libstd/ffi
parentf55ac6944a88d4da62b30a16cc95893ca050c328 (diff)
downloadrust-4e4d8baf7b99028a03280b90135117581c15d874.tar.gz
rust-4e4d8baf7b99028a03280b90135117581c15d874.zip
Add doc example for `std::ffi::CString::from_vec_unchecked`.
Diffstat (limited to 'src/libstd/ffi')
-rw-r--r--src/libstd/ffi/c_str.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index 77b90c0846b..18a7c7c8457 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -211,6 +211,17 @@ impl CString {
     /// This method is equivalent to `new` except that no runtime assertion
     /// is made that `v` contains no 0 bytes, and it requires an actual
     /// byte vector, not anything that can be converted to one with Into.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::ffi::CString;
+    ///
+    /// let raw = b"foo".to_vec();
+    /// unsafe {
+    ///     let c_string = CString::from_vec_unchecked(raw);
+    /// }
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
         v.push(0);