#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Dual {
primal: &'static str,
dual: &'static str,
}
impl Dual {
#[must_use]
pub const fn new(primal: &'static str, dual: &'static str) -> Self {
Self { primal, dual }
}
#[must_use]
pub const fn primal(self) -> &'static str {
self.primal
}
#[must_use]
pub const fn dual(self) -> &'static str {
self.dual
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Duality {
pair: Dual,
involutive: bool,
}
impl Duality {
#[must_use]
pub const fn new(pair: Dual, involutive: bool) -> Self {
Self { pair, involutive }
}
#[must_use]
pub const fn pair(self) -> Dual {
self.pair
}
#[must_use]
pub const fn is_involutive(self) -> bool {
self.involutive
}
}
#[cfg(test)]
mod tests {
use super::{Dual, Duality};
#[test]
fn stores_duality_metadata() {
let pair = Dual::new("cube", "octahedron");
let duality = Duality::new(pair, true);
assert_eq!(duality.pair().primal(), "cube");
assert_eq!(duality.pair().dual(), "octahedron");
assert!(duality.is_involutive());
}
}