pub struct LeanRef<T = LeanAny> { /* private fields */ }Expand description
An owned reference to a Lean object.
Unlike LeanBound, this is not tied to a Lean<'l> lifetime, so it can
be stored in structs and sent across threads (if the underlying type is Send).
To use a LeanRef, convert it to a LeanBound using bind().
Implementations§
Source§impl<T> LeanRef<T>
impl<T> LeanRef<T>
Sourcepub fn bind<'l>(&self, _lean: Lean<'l>) -> LeanBound<'l, T>
pub fn bind<'l>(&self, _lean: Lean<'l>) -> LeanBound<'l, T>
Bind this reference to a Lean<'l> lifetime.
This converts LeanRef<T> to LeanBound<'l, T> for use with Lean APIs.
Sourcepub unsafe fn from_owned_ptr(ptr: *mut lean_object) -> Self
pub unsafe fn from_owned_ptr(ptr: *mut lean_object) -> Self
Create a LeanRef from an owned pointer.
§Safety
ptrmust be a valid Lean object pointer- The reference count must already be incremented for this instance
Sourcepub fn as_ptr(&self) -> *mut lean_object
pub fn as_ptr(&self) -> *mut lean_object
Get the raw pointer to the Lean object.
Sourcepub fn into_unbound(self) -> LeanUnbound<T>
pub fn into_unbound(self) -> LeanUnbound<T>
Convert this LeanRef to a thread-safe LeanUnbound.
This marks the object for multi-threaded use via lean_mark_mt(),
enabling atomic reference counting.
§Example
ⓘ
let lean_ref: LeanRef<LeanString> = bound.unbind();
let unbound: LeanUnbound<LeanString> = lean_ref.into_unbound();
// unbound can now be safely sent across threadsTrait Implementations§
Source§impl<T> From<LeanRef<T>> for LeanUnbound<T>
impl<T> From<LeanRef<T>> for LeanUnbound<T>
impl<T: Send> Send for LeanRef<T>
impl<T: Sync> Sync for LeanRef<T>
Auto Trait Implementations§
impl<T> Freeze for LeanRef<T>
impl<T> RefUnwindSafe for LeanRef<T>where
T: RefUnwindSafe,
impl<T> Unpin for LeanRef<T>where
T: Unpin,
impl<T> UnwindSafe for LeanRef<T>where
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