Improve string functions.

This commit is contained in:
Stephen Chung
2022-03-17 17:00:48 +08:00
parent 6223e1a6f1
commit dc8c4ed8f4
3 changed files with 41 additions and 11 deletions

View File

@@ -344,7 +344,7 @@ impl<'a> NativeCallContext<'a> {
}
}
/// Consume a [`Shared`] resource and return a mutable reference to the wrapped value.
/// Return a mutable reference to the wrapped value of a [`Shared`] resource.
/// If the resource is shared (i.e. has other outstanding references), a cloned copy is used.
#[inline(always)]
#[must_use]
@@ -353,6 +353,14 @@ pub fn shared_make_mut<T: Clone>(value: &mut Shared<T>) -> &mut T {
Shared::make_mut(value)
}
/// Return a mutable reference to the wrapped value of a [`Shared`] resource.
#[inline(always)]
#[must_use]
#[allow(dead_code)]
pub fn shared_get_mut<T: Clone>(value: &mut Shared<T>) -> Option<&mut T> {
Shared::get_mut(value)
}
/// Consume a [`Shared`] resource if is unique (i.e. not shared), or clone it otherwise.
#[inline]
#[must_use]