summaryrefslogtreecommitdiff
path: root/engine-ecs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-08-04 19:53:35 +0200
committerHampusM <hampus@hampusmat.com>2026-08-04 19:53:35 +0200
commit4bb88a1a15bf79b9510c12fa729a680a52c75a54 (patch)
tree1a7a62b1ec85fab88ee6436c7e79b770e088a236 /engine-ecs
parentba10a14601f616a54964e8d36bde19d64a8be4d8 (diff)
feat(engine-ecs): add as_a & as_b fns to Either enum
Diffstat (limited to 'engine-ecs')
-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,