Skip to content

Commit 83d79c6

Browse files
committed
rollup merge of #24350: tbelaire/cstring-doc-from-vec
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. Since this is documentation: r? @steveklabnik
2 parents 9f7b6cb + 12d21bf commit 83d79c6

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
@@ -170,8 +170,9 @@ impl CString {
170170
/// Create a C-compatible string from a byte vector without checking for
171171
/// interior 0 bytes.
172172
///
173-
/// This method is equivalent to `from_vec` except that no runtime assertion
174-
/// is made that `v` contains no 0 bytes.
173+
/// This method is equivalent to `new` except that no runtime assertion
174+
/// is made that `v` contains no 0 bytes, and it requires an actual
175+
/// byte vector, not anyhting that can be converted to one with Into.
175176
#[stable(feature = "rust1", since = "1.0.0")]
176177
pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
177178
v.push(0);
@@ -213,7 +214,7 @@ impl fmt::Debug for CString {
213214

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

0 commit comments

Comments
 (0)