Skip to content

Commit 12d21bf

Browse files
committed
References to CString::from_vec changed to new
It looks like `from_vec` was subsumed by new at some point, but the documentation still refers to it as `from_vec`. This updates the documentation for `from_vec_unchecked` so that it properly says that it's the unchecked version of `new`. Also, from_vec_unchecked requires a actual Vec<u8> while new can take anything that is Into<Vec<u8>>, so I also mention that in the documentation.
1 parent 5afa270 commit 12d21bf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/libstd/ffi/c_str.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ impl CString {
172172
/// Create a C-compatible string from a byte vector without checking for
173173
/// interior 0 bytes.
174174
///
175-
/// This method is equivalent to `from_vec` except that no runtime assertion
176-
/// is made that `v` contains no 0 bytes.
175+
/// This method is equivalent to `new` except that no runtime assertion
176+
/// is made that `v` contains no 0 bytes, and it requires an actual
177+
/// byte vector, not anyhting that can be converted to one with Into.
177178
#[stable(feature = "rust1", since = "1.0.0")]
178179
pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
179180
v.push(0);
@@ -215,7 +216,7 @@ impl fmt::Debug for CString {
215216

216217
impl NulError {
217218
/// Returns the position of the nul byte in the slice that was provided to
218-
/// `CString::from_vec`.
219+
/// `CString::new`.
219220
#[stable(feature = "rust1", since = "1.0.0")]
220221
pub fn nul_position(&self) -> usize { self.0 }
221222

0 commit comments

Comments
 (0)