1use crate::prelude_::*;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
6pub struct TwoContainer<A: Object, B: Object> {
7 pub a: A,
8 pub b: B,
9}
10
11impl<A: Object, B: Object> TwoContainer<A, B> {
12 pub fn new(a: A, b: B) -> Self {
13 Self { a, b }
14 }
15}
16
17pub trait TwoContainerObject<B: Object>: Object {
18 fn and(self, other: B) -> TwoContainer<Self, B>
19 where
20 Self: Sized,
21 {
22 TwoContainer::new(self, other)
23 }
24
25 fn copy_and(self, process: impl FnOnce(Self) -> B) -> TwoContainer<Self, B>
26 where
27 Self: Sized,
28 Self: Copy,
29 {
30 TwoContainer::new(self, process(self))
31 }
32
33 fn clone_and(self, process: impl FnOnce(Self) -> B) -> TwoContainer<Self, B>
34 where
35 Self: Sized,
36 Self: Clone,
37 {
38 TwoContainer::new(self.clone(), process(self))
39 }
40}
41impl<A: Object, B: Object> TwoContainerObject<B> for A {}
42
43impl<A: Object, B: Object> Object for TwoContainer<A, B> {}
44
45#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
46#[cfg_attr(feature = "reflect", derive(bevy_reflect::Reflect))]
47pub struct ArrayContainer<T: Object, const N: usize> {
48 pub array: [T; N],
49}
50
51impl<T: Object, const N: usize> ArrayContainer<T, N> {}
52
53impl<T: Object, const N: usize> Object for ArrayContainer<T, N> {}