summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine-ecs/src/util.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/engine-ecs/src/util.rs b/engine-ecs/src/util.rs
index c52608a..a6925f7 100644
--- a/engine-ecs/src/util.rs
+++ b/engine-ecs/src/util.rs
@@ -139,6 +139,27 @@ pub enum Either<A, B>
B(B),
}
+impl<A, B> Either<A, B>
+{
+ #[inline]
+ pub fn as_a(&self) -> Option<&A>
+ {
+ match self {
+ Self::A(a) => Some(a),
+ Self::B(_) => None,
+ }
+ }
+
+ #[inline]
+ pub fn as_b(&self) -> Option<&B>
+ {
+ match self {
+ Self::A(_) => None,
+ Self::B(b) => Some(b),
+ }
+ }
+}
+
impl<A, B> Iterator for Either<A, B>
where
A: Iterator,