pub struct ResMut<'a, T: ?Sized> { /* private fields */ }Expand description
Resource borrowed mutably. Derefs to the resource type.
§Example
let mut world = World::new();
world.insert_resource(42i32);
let mut value: ResMut<i32> = world.expect_resource_mut();
*value = 11;Implementations§
Source§impl<'a, T> ResMut<'a, T>where
T: ?Sized,
impl<'a, T> ResMut<'a, T>where
T: ?Sized,
Sourcepub fn leak(r: ResMut<'a, T>) -> &'a mut T
pub fn leak(r: ResMut<'a, T>) -> &'a mut T
Convert into a mutable reference to the underlying data.
This function will consume the ResMut and keep data borrowed.
See World::undo_resource_leaks to undo all leaks.
This is an associated function that needs to be used as ResMut::leak(…).
A method would interfere with methods of the same name on the resource used through Deref.
§Example
let mut world = World::new();
world.insert_resource(42i32);
// Leaking reference to resource causes it to stay borrowed.
let value: &mut i32 = ResMut::leak(world.get_resource_mut().unwrap());
*value == 11;ⓘ
let mut world = World::new();
world.insert_resource(42i32);
// Leaking reference to resource causes it to stay borrowed.
let value: &mut i32 = ResMut::leak(world.get_resource_mut().unwrap());
// Immutable borrow panics.
world.get_resource::<i32>();Trait Implementations§
Source§impl<'a, T> BorrowMut<T> for ResMut<'a, T>where
T: ?Sized,
impl<'a, T> BorrowMut<T> for ResMut<'a, T>where
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<'a, T> FnArg for ResMut<'a, T>where
T: Send + 'static,
impl<'a, T> FnArg for ResMut<'a, T>where
T: Send + 'static,
Source§type State = ResMutState<T>
type State = ResMutState<T>
State for an argument that is stored between calls to function-system.
Auto Trait Implementations§
impl<'a, T> Freeze for ResMut<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for ResMut<'a, T>where
T: RefUnwindSafe + ?Sized,
impl<'a, T> Send for ResMut<'a, T>
impl<'a, T> Sync for ResMut<'a, T>
impl<'a, T> Unpin for ResMut<'a, T>where
T: ?Sized,
impl<'a, T> !UnwindSafe for ResMut<'a, T>
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<'de, F, T> Deserialize<'de, As<F>> for T
impl<'de, F, T> Deserialize<'de, As<F>> for T
Source§fn deserialize(deserializer: Deserializer<'de>) -> Result<T, DeserializeError>
fn deserialize(deserializer: Deserializer<'de>) -> Result<T, DeserializeError>
Deserializes value provided deserializer.
Returns deserialized value and the number of bytes consumed from
the and of input. Read more
Source§fn deserialize_in_place(
&mut self,
deserializer: Deserializer<'de>,
) -> Result<(), DeserializeError>
fn deserialize_in_place( &mut self, deserializer: Deserializer<'de>, ) -> Result<(), DeserializeError>
Deserializes value in-place provided deserializer.
Overwrites
self with data from the input. Read moreSource§impl<'de, F, T> Deserialize<'de, Ref<F>> for T
impl<'de, F, T> Deserialize<'de, Ref<F>> for T
Source§fn deserialize(de: Deserializer<'de>) -> Result<T, DeserializeError>
fn deserialize(de: Deserializer<'de>) -> Result<T, DeserializeError>
Deserializes value provided deserializer.
Returns deserialized value and the number of bytes consumed from
the and of input. Read more
Source§fn deserialize_in_place(
&mut self,
de: Deserializer<'de>,
) -> Result<(), DeserializeError>
fn deserialize_in_place( &mut self, de: Deserializer<'de>, ) -> Result<(), DeserializeError>
Deserializes value in-place provided deserializer.
Overwrites
self with data from the input. Read moreSource§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