Struct oxygengine_core::ecs::pipeline::RefMut
source · pub struct RefMut<'a, T>where
T: ?Sized,{ /* private fields */ }
Expand description
Unique borrow of an entity’s component
Implementations§
source§impl<'a, T> RefMut<'a, T>where
T: ?Sized,
impl<'a, T> RefMut<'a, T>where T: ?Sized,
sourcepub fn map<U, F>(orig: RefMut<'a, T>, f: F) -> RefMut<'a, U>where
F: FnOnce(&mut T) -> &mut U,
U: ?Sized,
pub fn map<U, F>(orig: RefMut<'a, T>, f: F) -> RefMut<'a, U>where F: FnOnce(&mut T) -> &mut U, U: ?Sized,
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> Send for RefMut<'_, T>where T: Send + ?Sized,
impl<T> Sync for RefMut<'_, T>where T: Sync + ?Sized,
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