Skip to content

Commit 05f7269

Browse files
authored
Add a Thread::from_raw_unchecked (#135)
Add a Thread::from_raw_unchecked, which is to `Thread::from_raw` as `NonNull::new_unchecked` is to `NonNull::new`.
1 parent 73d1e08 commit 05f7269

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/thread/linux_raw.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ impl Thread {
4646
Self(NonNull::new(raw.cast()).unwrap())
4747
}
4848

49+
/// Convert to `Self` from a raw non-null pointer.
50+
///
51+
/// # Safety
52+
///
53+
/// `raw` must be a valid non-null thread pointer.
54+
#[inline]
55+
pub unsafe fn from_raw_unchecked(raw: *mut c_void) -> Self {
56+
Self(NonNull::new_unchecked(raw.cast()))
57+
}
58+
4959
/// Convert to `Self` from a raw non-null pointer that was returned from
5060
/// `Thread::to_raw_non_null`.
5161
#[inline]

0 commit comments

Comments
 (0)