Skip to content

Commit 3771c65

Browse files
committed
add safety doc for CString::from_vec_unchecked and async_drop_in_place
1 parent ea5573a commit 3771c65

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

library/alloc/src/ffi/c_str.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ impl CString {
321321
/// assertion is made that `v` contains no 0 bytes, and it requires an
322322
/// actual byte vector, not anything that can be converted to one with Into.
323323
///
324+
/// # Safety
325+
///
326+
/// The caller must ensure `v` contains no nul bytes in its contents.
327+
///
324328
/// # Examples
325329
///
326330
/// ```

library/core/src/future/async_drop.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ pub trait AsyncDrop {
4141
}
4242

4343
/// Async drop.
44+
///
45+
/// # Safety
46+
///
47+
/// The pointer `_to_drop` must be valid for both reads and writes,
48+
/// not only for the duration of this function call,
49+
/// but also until the returned future has completed.
50+
/// See [ptr::drop_in_place] for additional safety concerns.
51+
///
52+
/// [ptr::drop_in_place]: crate::ptr::drop_in_place()
4453
#[unstable(feature = "async_drop", issue = "126482")]
4554
#[lang = "async_drop_in_place"]
4655
pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: *mut T) {

0 commit comments

Comments
 (0)