use crate::{
component::Component,
iter::IntoAbstract,
view::{View, ViewMut},
Inserted, InsertedOrModified, Modified,
};
use core::ops::BitOr;
#[derive(Copy, Clone)]
pub struct Or<T>(pub(crate) T);
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a View<'a, T> {
type Output = Or<(Self, U)>;
fn bitor(self, rhs: U) -> Self::Output {
Or((self, rhs))
}
}
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for Inserted<&'a View<'a, T>> {
type Output = Or<(Self, U)>;
fn bitor(self, rhs: U) -> Self::Output {
Or((self, rhs))
}
}
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for Modified<&'a View<'a, T>> {
type Output = Or<(Self, U)>;
fn bitor(self, rhs: U) -> Self::Output {
Or((self, rhs))
}
}
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for InsertedOrModified<&'a View<'a, T>> {
type Output = Or<(Self, U)>;
fn bitor(self, rhs: U) -> Self::Output {
Or((self, rhs))
}
}
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a ViewMut<'a, T> {
type Output = Or<(Self, U)>;
fn bitor(self, rhs: U) -> Self::Output {
Or((self, rhs))
}
}
impl<'a, T: Component, U: IntoAbstract> BitOr<U> for &'a mut ViewMut<'a, T> {
type Output = Or<(Self, U)>;
fn bitor(self, rhs: U) -> Self::Output {
Or((self, rhs))
}
}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub enum OneOfTwo<T, U> {
#[allow(missing_docs)]
One(T),
#[allow(missing_docs)]
Two(U),
}
impl From<usize> for OneOfTwo<usize, usize> {
fn from(_: usize) -> Self {
unreachable!()
}
}