archway 0.4.0

Rust traits for Rc and Arc interoperation
Documentation
use alloc::sync::{Arc, Weak};

use crate::kind::PointerKind;
use crate::shared::AnySharedPointer;
use crate::weak::AnyWeakPointer;

impl<T> AnySharedPointer<T> for Arc<T> {
    type Weak = Weak<T>;
    fn downgrade(&self) -> Self::Weak {
        Arc::downgrade(self)
    }
    fn from(value: T) -> Self {
        Self::new(value)
    }
}
impl<T> AnyWeakPointer<T> for Weak<T> {
    type Shared = Arc<T>;
    fn upgrade(&self) -> Option<Self::Shared> {
        Weak::upgrade(self)
    }
}

/// [`PointerKind`] implementor for [`Arc`].
#[derive(Debug, Copy, Clone)]
pub struct ArcKind;

impl PointerKind for ArcKind {
    type Shared<T> = Arc<T>;
    type Weak<T> = Weak<T>;
}