pub struct MiraContext { /* private fields */ }Expand description
Globals visible to a MiraScript execution.
Implementations§
Source§impl MiraContext
impl MiraContext
Sourcepub fn insert(
&mut self,
name: impl Into<String>,
value: impl Into<MiraAny>,
) -> Option<MiraAny>
pub fn insert( &mut self, name: impl Into<String>, value: impl Into<MiraAny>, ) -> Option<MiraAny>
Insert or replace a global value, returning the previous value.
§Examples
use mirascript_vm::{MiraAny, MiraContext};
let mut context = MiraContext::empty();
assert_eq!(context.insert("answer", 42), None);
assert_eq!(context.get("answer"), Some(MiraAny::Number(42.0)));Trait Implementations§
Source§impl Clone for MiraContext
impl Clone for MiraContext
Source§fn clone(&self) -> MiraContext
fn clone(&self) -> MiraContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for MiraContext
impl !Send for MiraContext
impl !Sync for MiraContext
impl !UnwindSafe for MiraContext
impl Freeze for MiraContext
impl Unpin for MiraContext
impl UnsafeUnpin for MiraContext
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