mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-30 14:52:56 +03:00
Added the documentation about length to CString::from_raw
This commit is contained in:
@@ -395,6 +395,12 @@ pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
|
||||
/// ownership of a string that was allocated by foreign code) is likely to lead
|
||||
/// to undefined behavior or allocator corruption.
|
||||
///
|
||||
/// It should be noted that the length isn't just "recomputed," but that
|
||||
/// the recomputed length must match the original length from the
|
||||
/// [`into_raw`] call. This means the [`into_raw`]/`from_raw` methods
|
||||
/// should not be used when passing the string to C functions that can
|
||||
/// modify the string's length.
|
||||
///
|
||||
/// > **Note:** If you need to borrow a string that was allocated by
|
||||
/// > foreign code, use [`CStr`]. If you need to take ownership of
|
||||
/// > a string that was allocated by foreign code, you will need to
|
||||
|
||||
Reference in New Issue
Block a user