#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "std")]
use std::{rc::Rc, cell::RefCell};
#[cfg(all(feature = "std", feature = "sync"))]
use std::sync::{Arc, Mutex};
use core::cell::Cell;
pub trait WrapExt: Sized {
#[inline(always)]
fn cell(self) -> Cell<Self>
where
Self: Copy,
{
Cell::new(self)
}
#[cfg(feature = "std")]
#[inline(always)]
fn refcell(self) -> RefCell<Self> {
RefCell::new(self)
}
#[cfg(feature = "std")]
#[inline(always)]
fn rc(self) -> Rc<Self> {
Rc::new(self)
}
#[cfg(feature = "std")]
#[inline(always)]
fn rc_refcell(self) -> Rc<RefCell<Self>> {
Rc::new(RefCell::new(self))
}
#[cfg(all(feature = "std", feature = "sync"))]
#[inline(always)]
fn arc(self) -> Arc<Self> {
Arc::new(self)
}
#[cfg(all(feature = "std", feature = "sync"))]
#[inline(always)]
fn arc_mutex(self) -> Arc<Mutex<Self>> {
Arc::new(Mutex::new(self))
}
}
impl<T> WrapExt for T {}