pub struct RefMut<'a, T: ?Sized> { /* private fields */ }
Expand description
Unique borrow of an entity’s component
Implementations§
source§impl<'a, T: ?Sized> RefMut<'a, T>
impl<'a, T: ?Sized> RefMut<'a, T>
sourcepub fn map<U: ?Sized, F>(orig: RefMut<'a, T>, f: F) -> RefMut<'a, U>
pub fn map<U: ?Sized, F>(orig: RefMut<'a, T>, f: F) -> RefMut<'a, U>
Transform the RefMut<'_, T>
to point to a part of the borrowed data, e.g.
a struct field.
The RefMut<'_, T>
is already mutably borrowed, so this cannot fail.
Examples
struct Component {
member: i32,
}
let component_ref = entity_ref.get::<&mut Component>()
.expect("Entity does not contain an instance of \"Component\"");
let mut member_ref = RefMut::map(component_ref, |component| &mut component.member);
*member_ref = 21;
println!("member = {:?}", *member_ref);
Trait Implementations§
impl<T: ?Sized + Send> Send for RefMut<'_, T>
impl<T: ?Sized + Sync> Sync for RefMut<'_, T>
Auto Trait Implementations§
impl<'a, T: ?Sized> RefUnwindSafe for RefMut<'a, T>where
T: RefUnwindSafe,
impl<'a, T: ?Sized> Unpin for RefMut<'a, T>
impl<'a, T> !UnwindSafe for RefMut<'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