Refine immutable strings.

This commit is contained in:
Stephen Chung
2020-05-25 17:01:39 +08:00
parent 99ea2b33c9
commit fca140ef55
6 changed files with 119 additions and 39 deletions

View File

@@ -19,6 +19,28 @@ pub type Shared<T> = Rc<T>;
#[cfg(feature = "sync")]
pub type Shared<T> = Arc<T>;
pub fn shared_make_mut<T: Clone>(value: &mut Shared<T>) -> &mut T {
#[cfg(not(feature = "sync"))]
{
Rc::make_mut(value)
}
#[cfg(feature = "sync")]
{
Arc::make_mut(value)
}
}
pub fn shared_unwrap<T: Clone>(value: Shared<T>) -> Result<T, Shared<T>> {
#[cfg(not(feature = "sync"))]
{
Rc::try_unwrap(value)
}
#[cfg(feature = "sync")]
{
Arc::try_unwrap(value)
}
}
pub type FnCallArgs<'a> = [&'a mut Dynamic];
#[cfg(not(feature = "sync"))]