Skip to content

Commit 0017bc4

Browse files
authored
Add Arc::as_ptr (#230)
1 parent 89c4ba7 commit 0017bc4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sync/arc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ impl<T> Arc<T> {
7575

7676
/// Consumes the `Arc`, returning the wrapped pointer.
7777
pub fn into_raw(this: Self) -> *const T {
78-
let ptr = &*this as *const _;
78+
let ptr = Self::as_ptr(&this);
7979
mem::forget(this);
80-
ptr as *const T
80+
ptr
81+
}
82+
83+
/// Provides a raw pointer to the data.
84+
pub fn as_ptr(this: &Self) -> *const T {
85+
std::sync::Arc::as_ptr(&this.inner) as *const T
8186
}
8287

8388
/// Constructs an `Arc` from a raw pointer.

0 commit comments

Comments
 (0)