Skip to main content

ToExactBinaryRelation

Trait ToExactBinaryRelation 

Source
pub trait ToExactBinaryRelation<A, B>: ExactSupport<(A, B)>
where A: Ord + Clone, B: Ord + Clone,
{ // 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§

Source

fn to_binary_relation(&self) -> BinaryRelation<A, B>

Materializes exact pair support as a binary relation.

Examples found in repository?
examples/capability_boundaries.rs (line 17)
10fn exact_pairs<R>(relation: &R) -> BinaryRelation<&'static str, &'static str>
11where
12    R: ExactSupport<(&'static str, &'static str)>
13        + ToExactBinaryRelation<&'static str, &'static str>,
14{
15    assert_eq!(
16        relation.exact_support().to_vec(),
17        relation.to_binary_relation().to_vec()
18    );
19    relation.to_binary_relation()
20}

Implementors§

Source§

impl<A, B, R> ToExactBinaryRelation<A, B> for R
where A: Ord + Clone, B: Ord + Clone, R: ExactSupport<(A, B)>,