pub struct Or<T>(_);
Expand description
Yield the entities that have a component or another.
Example
use shipyard::{Component, IntoIter, OneOfTwo, View, ViewMut, World};
#[derive(Component, PartialEq, Eq, Debug)]
#[track(All)]
struct A(u32);
#[derive(Component, PartialEq, Eq, Debug)]
#[track(All)]
struct B(u32);
let mut world = World::new();
world.add_entity((A(0),));
world.add_entity((A(1), B(10)));
world.borrow::<ViewMut<A>>().unwrap().clear_all_inserted();
world.add_entity((B(20),));
world.add_entity((A(3),));
let (a, b) = world.borrow::<(View<A>, View<B>)>().unwrap();
assert_eq!(
(a.inserted() | b.inserted()).iter().collect::<Vec<_>>(),
vec![
OneOfTwo::One(&A(3)),
OneOfTwo::Two(&B(10)),
OneOfTwo::Two(&B(20))
]
);
Trait Implementations
sourceimpl<T: AbstractMut, U: AbstractMut> AbstractMut for Or<(T, U)> where
<U as AbstractMut>::Index: Into<usize> + Clone,
impl<T: AbstractMut, U: AbstractMut> AbstractMut for Or<(T, U)> where
<U as AbstractMut>::Index: Into<usize> + Clone,
type Out = OneOfTwo<<T as AbstractMut>::Out, <U as AbstractMut>::Out>
type Index = OneOfTwo<<T as AbstractMut>::Index, <U as AbstractMut>::Index>
sourceimpl<'a: 'b, 'b, T: IntoAbstract, U: IntoAbstract> IntoAbstract for Or<(T, U)> where
<<U as IntoAbstract>::AbsView as AbstractMut>::Index: Into<usize> + Clone,
impl<'a: 'b, 'b, T: IntoAbstract, U: IntoAbstract> IntoAbstract for Or<(T, U)> where
<<U as IntoAbstract>::AbsView as AbstractMut>::Index: Into<usize> + Clone,
type AbsView = Or<(<T as IntoAbstract>::AbsView, <U as IntoAbstract>::AbsView)>
impl<T: Copy> Copy for Or<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Or<T> where
T: RefUnwindSafe,
impl<T> Send for Or<T> where
T: Send,
impl<T> Sync for Or<T> where
T: Sync,
impl<T> Unpin for Or<T> where
T: Unpin,
impl<T> UnwindSafe for Or<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more