pub trait ToExactBinaryRelation<A, B>: ExactSupport<(A, B)>{
// Provided method
fn to_binary_relation(&self) -> BinaryRelation<A, B> { ... }
}Expand description
Shared exact-support and materialization capability traits for add-on relation surfaces. Materializes exact pair support as a binary relation.
This trait mirrors the existing to_binary_relation conversion methods on
released add-on surfaces and keeps deterministic pair order inherited from
exact support materialization.
§Examples
use relmath::{
BinaryRelation, ToExactBinaryRelation,
annotated::{AnnotatedRelation, BooleanSemiring},
};
fn exact_pairs<R>(relation: &R) -> BinaryRelation<&'static str, &'static str>
where
R: ToExactBinaryRelation<&'static str, &'static str>,
{
relation.to_binary_relation()
}
let permissions = AnnotatedRelation::from_facts([
(("alice", "read"), BooleanSemiring::TRUE),
(("bob", "approve"), BooleanSemiring::TRUE),
]);
assert_eq!(
exact_pairs(&permissions).to_vec(),
vec![("alice", "read"), ("bob", "approve")]
);Provided Methods§
Sourcefn to_binary_relation(&self) -> BinaryRelation<A, B>
fn to_binary_relation(&self) -> BinaryRelation<A, B>
Materializes exact pair support as a binary relation.