Struct ResMut

Source
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,

Source

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, U> AsMut<U> for ResMut<'a, T>
where T: AsMut<U> + ?Sized,

Source§

fn as_mut(&mut self) -> &mut U

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<'a, T, U> AsRef<U> for ResMut<'a, T>
where T: AsRef<U> + ?Sized,

Source§

fn as_ref(&self) -> &U

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, T> Borrow<T> for ResMut<'a, T>
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<'a, T> BorrowMut<T> for ResMut<'a, T>
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Debug for ResMut<'_, T>
where T: Debug + ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T> Deref for ResMut<'a, T>
where T: ?Sized,

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<'a, T> DerefMut for ResMut<'a, T>
where T: ?Sized,

Source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.
Source§

impl<T> Display for ResMut<'_, T>
where T: Display + ?Sized,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T> FnArg for ResMut<'a, T>
where T: Send + 'static,

Source§

type State = ResMutState<T>

State for an argument that is stored between calls to function-system.
Source§

impl<'a, T> Hash for ResMut<'a, T>
where T: Hash + ?Sized,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, T, U> PartialEq<U> for ResMut<'a, T>
where T: PartialEq<U> + ?Sized,

Source§

fn eq(&self, other: &U) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T, U> PartialOrd<U> for ResMut<'a, T>
where T: PartialOrd<U> + ?Sized,

Source§

fn partial_cmp(&self, other: &U) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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>
where T: Send + ?Sized,

§

impl<'a, T> Sync for ResMut<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Unpin for ResMut<'a, T>
where T: ?Sized,

§

impl<'a, T> !UnwindSafe for ResMut<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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
where F: BareFormula + ?Sized, T: Deserialize<'de, F>,

Source§

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>

Deserializes value in-place provided deserializer. Overwrites self with data from the input. Read more
Source§

impl<'de, F, T> Deserialize<'de, Ref<F>> for T
where F: BareFormula + ?Sized, T: Deserialize<'de, F> + ?Sized,

Source§

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>

Deserializes value in-place provided deserializer. Overwrites self with data from the input. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<F, T> Serialize<As<F>> for T
where F: BareFormula + ?Sized, T: Serialize<F>,

Source§

fn serialize<B>( self, sizes: &mut Sizes, buffer: B, ) -> Result<(), <B as Buffer>::Error>
where B: Buffer,

Serializes self into the given buffer. heap specifies the size of the buffer’s heap occupied prior to this call. Read more
Source§

fn size_hint(&self) -> Option<Sizes>

Returns heap and stack sizes required to serialize self. If some sizes are returned they must be exact. Read more
Source§

impl<F, T> Serialize<Ref<F>> for T
where F: BareFormula + ?Sized, T: Serialize<F>,

Source§

fn serialize<B>( self, sizes: &mut Sizes, buffer: B, ) -> Result<(), <B as Buffer>::Error>
where B: Buffer,

Serializes self into the given buffer. heap specifies the size of the buffer’s heap occupied prior to this call. Read more
Source§

fn size_hint(&self) -> Option<Sizes>

Returns heap and stack sizes required to serialize self. If some sizes are returned they must be exact. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.