We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 74549f8 + 4e4d8ba commit b444ac6Copy full SHA for b444ac6
src/libstd/ffi/c_str.rs
@@ -211,6 +211,17 @@ impl CString {
211
/// This method is equivalent to `new` except that no runtime assertion
212
/// is made that `v` contains no 0 bytes, and it requires an actual
213
/// byte vector, not anything that can be converted to one with Into.
214
+ ///
215
+ /// # Examples
216
217
+ /// ```
218
+ /// use std::ffi::CString;
219
220
+ /// let raw = b"foo".to_vec();
221
+ /// unsafe {
222
+ /// let c_string = CString::from_vec_unchecked(raw);
223
+ /// }
224
225
#[stable(feature = "rust1", since = "1.0.0")]
226
pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
227
v.push(0);
0 commit comments