pub struct Context<'a> { /* private fields */ }Expand description
Holds all data necessary for the execution of the world. The data is held by references, and needs to outlive the context itself
Implementations§
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn new(data: &'a dyn Data) -> Context<'_>
pub fn new(data: &'a dyn Data) -> Context<'_>
Construct a new context from the tuple of references data
Sourcepub fn borrow<T>(&'a self) -> Result<T::Target>where
T: ContextBorrow<'a>,
pub fn borrow<T>(&'a self) -> Result<T::Target>where
T: ContextBorrow<'a>,
Borrows data of type T from the context. Does not panic.
Sourcepub fn cell<T: IntoAccess>(&'a self) -> Result<&AtomicRefCell<NonNull<u8>>>
pub fn cell<T: IntoAccess>(&'a self) -> Result<&AtomicRefCell<NonNull<u8>>>
Returns the cell associated to T.
Note: Types are erased, but casting is guaranteed to be correct.
Trait Implementations§
impl Send for Context<'_>
impl Sync for Context<'_>
Auto Trait Implementations§
impl<'a> Freeze for Context<'a>
impl<'a> !RefUnwindSafe for Context<'a>
impl<'a> Unpin for Context<'a>
impl<'a> !UnwindSafe for Context<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more