#![allow(dead_code, deprecated, unused_variables, unused_mut)] use std::cell::Cell; use std::ptr::NonNull; use std::process::abort; use std::marker::PhantomData; struct Rc { ptr: NonNull>, phantom: PhantomData>, } struct RcInner { strong: Cell, refcount: Cell, value: T, } impl Clone for Rc { fn clone(&self) -> Rc { self.inc_strong(); Rc { ptr: self.ptr, phantom: PhantomData, } } } trait RcInnerPtr { fn inner(&self) -> &RcInner; fn strong(&self) -> usize { self.inner().strong.get() } fn inc_strong(&self) { self.inner().strong.set(self.strong().checked_add(1).unwrap_or_else(|| abort())); } } impl RcInnerPtr for Rc { fn inner(&self) -> &RcInner { unsafe { self.ptr.as_ref() } } } fn main() {}