morethantext/src/router.rs
Jeff Baskin fd9754d224
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Moved include into router.
2025-12-26 13:48:02 -05:00

35 lines
917 B
Rust

#[derive(Clone, Debug, Eq, Hash)]
pub enum Include<T> {
All,
Just(T),
}
impl<T: PartialEq> PartialEq for Include<T> {
fn eq(&self, other: &Self) -> bool {
match self {
Include::All => true,
Include::Just(data) => match other {
Include::All => true,
Include::Just(other_data) => data == other_data,
},
}
}
}
#[cfg(test)]
mod includes {
use super::*;
#[test]
fn does_all_equal_evberything() {
let a: Include<isize> = Include::All;
let b: Include<isize> = Include::Just(5);
let c: Include<isize> = Include::Just(7);
assert!(a == a, "all should equal all");
assert!(a == b, "all should equal some");
assert!(b == a, "some should equal all");
assert!(b == b, "same some should equal");
assert!(b != c, "different somes do not equal");
}
}