#[repr(transparent)]pub struct RcAnchor<T>(pub Rc<T>);Expand description
A wrapper around Rc<T> that opts a field into anchor emission (e.g. serialization by reference).
This type behaves like a normal Rc<T> but signals that the value
should be treated as an anchorable reference — for instance,
when serializing graphs or shared structures where pointer identity matters.
§Examples
use std::rc::Rc;
use serde_saphyr::RcAnchor;
// Create from an existing Rc
let rc = Rc::new(String::from("Hello"));
let anchor1 = RcAnchor::from(rc.clone());
// Or directly from a value (Rc::new is called internally)
let anchor2: RcAnchor<String> = RcAnchor::from(Rc::new(String::from("World")));
assert_eq!(*anchor1.0, "Hello");
assert_eq!(*anchor2.0, "World");Tuple Fields§
§0: Rc<T>Implementations§
Trait Implementations§
impl<T> Eq for RcAnchor<T>
Source§impl<T> From<&RcAnchor<T>> for RcWeakAnchor<T>
impl<T> From<&RcAnchor<T>> for RcWeakAnchor<T>
Auto Trait Implementations§
impl<T> !Send for RcAnchor<T>
impl<T> !Sync for RcAnchor<T>
impl<T> Freeze for RcAnchor<T>
impl<T> RefUnwindSafe for RcAnchor<T>where
Rc<T>: RefUnwindSafe,
impl<T> Unpin for RcAnchor<T>
impl<T> UnsafeUnpin for RcAnchor<T>where
Rc<T>: UnsafeUnpin,
impl<T> UnwindSafe for RcAnchor<T>where
Rc<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more