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