pub struct MiraShared<T> { /* private fields */ }Expand description
Shared ownership used when the host needs to retain and mutate a value.
Implementations§
Sourcepub fn new(value: T) -> Self
pub fn new(value: T) -> Self
Wrap a value in single-threaded shared ownership.
§Examples
use mirascript_vm::MiraShared;
let value = MiraShared::new(vec![1, 2]);
value.borrow_mut().push(3);
assert_eq!(&*value.borrow(), &[1, 2, 3]);Sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Immutably borrow the wrapped Rust value.
Panics when the value is already mutably borrowed. VM bridge access uses
checked borrows and reports crate::MiraError::BorrowConflict instead.
Sourcepub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Mutably borrow the wrapped Rust value.
Panics when another borrow is active. VM bridge access uses checked
borrows and reports crate::MiraError::BorrowConflict instead.
Trait Implementations§
Auto Trait Implementations§
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