Skip to content

Instantly share code, notes, and snippets.

View knappador's full-sized avatar
💭
First posty toasty

knappador

💭
First posty toasty
View GitHub Profile
@rust-play
rust-play / playground.rs
Created May 19, 2019 16:40
Code shared from the Rust Playground
use std::ptr::NonNull;
use std::sync::Arc;
pub struct UniqueArc<T>(NonNull<T>);
impl<T> From<T> for UniqueArc<T> {
fn from(value: T) -> Self {
unsafe {
Self(NonNull::new_unchecked(
Arc::into_raw(Arc::new(value)) as *mut T