]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #89315 - et342:cstr_from_vec_unchecked_doc, r=yaahc
authorEric Huss <eric@huss.org>
Thu, 30 Sep 2021 02:33:41 +0000 (19:33 -0700)
committerGitHub <noreply@github.com>
Thu, 30 Sep 2021 02:33:41 +0000 (19:33 -0700)
Clarify that `CString::from_vec_unchecked` appends 0 byte.

library/std/src/ffi/c_str.rs

index ba084987f66e1d532f33767ad2b00d6f112c15a0..fe1f28f00c4031aa8291120b6afc9ba5b842ffef 100644 (file)
@@ -409,6 +409,8 @@ fn _new(bytes: Vec<u8>) -> Result<CString, NulError> {
     /// Creates a C-compatible string by consuming a byte vector,
     /// without checking for interior 0 bytes.
     ///
+    /// Trailing 0 byte will be appended by this function.
+    ///
     /// This method is equivalent to [`CString::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.