Skip to main content

ToExactUnaryRelation

Trait ToExactUnaryRelation 

Source
pub trait ToExactUnaryRelation<T>: ExactSupport<T>
where T: Ord + Clone,
{ // Provided method fn to_unary_relation(&self) -> UnaryRelation<T> { ... } }
Expand description

Shared exact-support and materialization capability traits for add-on relation surfaces. Materializes exact scalar support as a unary relation.

This trait mirrors the existing to_unary_relation conversion methods on released add-on surfaces and gives generic code one explicit unary materialization boundary.

§Examples

use relmath::{
    ToExactUnaryRelation,
    annotated::{AnnotatedRelation, BooleanSemiring},
};

fn exact_values<R>(relation: &R) -> Vec<&'static str>
where
    R: ToExactUnaryRelation<&'static str>,
{
    relation.to_unary_relation().to_vec()
}

let concepts = AnnotatedRelation::from_facts([
    ("Closure", BooleanSemiring::TRUE),
    ("Relations", BooleanSemiring::TRUE),
    ("Zero", BooleanSemiring::FALSE),
]);

assert_eq!(exact_values(&concepts), vec!["Closure", "Relations"]);

Provided Methods§

Source

fn to_unary_relation(&self) -> UnaryRelation<T>

Materializes exact scalar support as a unary relation.

Implementors§

Source§

impl<T, R> ToExactUnaryRelation<T> for R
where T: Ord + Clone, R: ExactSupport<T>,