pub enum Term {
Var(String),
Const(String),
Typed {
value: Box<Term>,
type_annotation: TypeAnnotation,
},
}Variants§
Implementations§
Source§impl Term
impl Term
Sourcepub fn var(name: impl Into<String>) -> Term
pub fn var(name: impl Into<String>) -> Term
Examples found in repository?
examples/00_minimal_rule/main.rs (line 11)
4fn main() {
5 println!("=== Tensorlogic Example: Minimal Rule ===\n");
6
7 // Define a simple implication rule:
8 // Parent(a, b) → Ancestor(a, b)
9 // "If a is a parent of b, then a is an ancestor of b"
10
11 let parent = TLExpr::pred("Parent", vec![Term::var("a"), Term::var("b")]);
12
13 let ancestor = TLExpr::pred("Ancestor", vec![Term::var("a"), Term::var("b")]);
14
15 let rule = TLExpr::imply(parent, ancestor);
16
17 println!("Rule: Parent(a, b) → Ancestor(a, b)");
18 println!("Compiling logic rule to tensor graph...\n");
19
20 match compile_to_einsum(&rule) {
21 Ok(plan) => {
22 println!("Compilation successful!");
23 println!(" Tensors: {}", plan.tensors.len());
24 println!(" Nodes: {}", plan.nodes.len());
25 println!("\nGenerated tensors:");
26 for (i, tensor) in plan.tensors.iter().enumerate() {
27 println!(" {}: {}", i, tensor);
28 }
29 println!("\nGenerated nodes:");
30 for (i, node) in plan.nodes.iter().enumerate() {
31 println!(" {}: {:?} (inputs: {:?})", i, node.op, node.inputs);
32 }
33 }
34 Err(e) => {
35 eprintln!("Compilation error: {}", e);
36 }
37 }
38
39 println!("\n=== Compilation Complete ===");
40}More examples
examples/04_compilation_strategies/main.rs (line 27)
19fn main() {
20 let sep = "=".repeat(70);
21 println!("{}", sep);
22 println!("TensorLogic - Compilation Strategies Comparison");
23 println!("{}", sep);
24 println!();
25
26 // Create a simple logical expression: P(x) AND Q(x)
27 let p = TLExpr::pred("P", vec![Term::var("x")]);
28 let q = TLExpr::pred("Q", vec![Term::var("x")]);
29 let and_expr = TLExpr::and(p.clone(), q.clone());
30
31 // Test data: 5 different cases
32 // P values: [0.0, 0.2, 0.5, 0.8, 1.0]
33 // Q values: [1.0, 0.8, 0.5, 0.2, 0.0]
34 let p_data =
35 Scirs2Exec::from_vec(vec![0.0, 0.2, 0.5, 0.8, 1.0], vec![5]).expect("valid tensor data");
36 let q_data =
37 Scirs2Exec::from_vec(vec![1.0, 0.8, 0.5, 0.2, 0.0], vec![5]).expect("valid tensor data");
38
39 println!("Test Data:");
40 println!(" P(x): {:?}", p_data.as_slice().unwrap_or(&[]));
41 println!(" Q(x): {:?}", q_data.as_slice().unwrap_or(&[]));
42 println!();
43
44 // Test each compilation strategy
45 test_strategy(
46 "Soft Differentiable",
47 &and_expr,
48 &p_data,
49 &q_data,
50 CompilationConfig::soft_differentiable(),
51 );
52
53 test_strategy(
54 "Hard Boolean",
55 &and_expr,
56 &p_data,
57 &q_data,
58 CompilationConfig::hard_boolean(),
59 );
60
61 test_strategy(
62 "Fuzzy Gödel",
63 &and_expr,
64 &p_data,
65 &q_data,
66 CompilationConfig::fuzzy_godel(),
67 );
68
69 test_strategy(
70 "Fuzzy Product",
71 &and_expr,
72 &p_data,
73 &q_data,
74 CompilationConfig::fuzzy_product(),
75 );
76
77 test_strategy(
78 "Fuzzy Łukasiewicz",
79 &and_expr,
80 &p_data,
81 &q_data,
82 CompilationConfig::fuzzy_lukasiewicz(),
83 );
84
85 test_strategy(
86 "Probabilistic",
87 &and_expr,
88 &p_data,
89 &q_data,
90 CompilationConfig::probabilistic(),
91 );
92
93 println!();
94 let sep = "=".repeat(70);
95 println!("{}", sep);
96 println!("Analysis:");
97 println!("{}", sep);
98 println!();
99 println!("1. Soft Differentiable (Product):");
100 println!(" - Smooth, differentiable everywhere");
101 println!(" - Good for gradient-based optimization");
102 println!(" - Penalizes low values more");
103 println!();
104 println!("2. Hard Boolean (Min):");
105 println!(" - Exact Boolean semantics");
106 println!(" - Not differentiable at certain points");
107 println!(" - Returns minimum of inputs");
108 println!();
109 println!("3. Fuzzy Gödel (Min):");
110 println!(" - Same as Hard Boolean for AND");
111 println!(" - Part of Gödel fuzzy logic system");
112 println!();
113 println!("4. Fuzzy Product (Product):");
114 println!(" - Similar to Soft Differentiable");
115 println!(" - Standard product t-norm");
116 println!();
117 println!("5. Fuzzy Łukasiewicz (max(0, a+b-1)):");
118 println!(" - Different from other strategies");
119 println!(" - More conservative (lower values)");
120 println!(" - Good for certain applications");
121 println!();
122 println!("6. Probabilistic (Product, assumes independence):");
123 println!(" - Treats values as probabilities");
124 println!(" - P(A AND B) = P(A) * P(B) if independent");
125 println!();
126 let sep = "=".repeat(70);
127 println!("{}", sep);
128 println!();
129 println!("Note: This example demonstrates how different compilation strategies");
130 println!("affect the semantics of logical operations. Each strategy compiles");
131 println!("the same logical expression to different tensor operations.");
132 println!();
133 let sep = "=".repeat(70);
134 println!("{}", sep);
135 println!("Example Complete!");
136 println!("{}", sep);
137}examples/01_exists_reduce/main.rs (line 22)
4fn main() {
5 println!("=== Tensorlogic Example: Exists Quantifier with Reduction ===\n");
6
7 // Define domains
8 let mut ctx = CompilerContext::new();
9 ctx.add_domain("Person", 10);
10 ctx.add_domain("City", 5);
11
12 println!("Domains defined:");
13 println!(" Person: cardinality = 10");
14 println!(" City: cardinality = 5\n");
15
16 // Example 1: Basic exists quantifier
17 // ∃z ∈ Person. Friend(x, z)
18 // "There exists a person z who is a friend of x"
19 println!("Example 1: ∃z ∈ Person. Friend(x, z)");
20 println!(" 'For each person x, check if there exists a friend z'");
21
22 let friend_pred = TLExpr::pred("Friend", vec![Term::var("x"), Term::var("z")]);
23 let exists_friend = TLExpr::exists("z", "Person", friend_pred);
24
25 match compile_to_einsum_with_context(&exists_friend, &mut ctx.clone()) {
26 Ok(graph) => {
27 println!(" Compiled successfully!");
28 println!(" Tensors: {}", graph.tensors.len());
29 println!(" Nodes: {}", graph.nodes.len());
30 println!(" Graph tensors: {:?}\n", graph.tensors);
31 }
32 Err(e) => println!(" Compilation error: {}\n", e),
33 }
34
35 // Example 2: Exists with conjunction
36 // ∃z ∈ Person. (Friend(x, z) ∧ LivesIn(z, "Tokyo"))
37 // "There exists a person z who is a friend of x AND lives in Tokyo"
38 println!("Example 2: ∃z ∈ Person. (Friend(x, z) ∧ LivesIn(z, Tokyo))");
39 println!(" 'For each person x, check if they have a friend in Tokyo'");
40
41 let friend_pred2 = TLExpr::pred("Friend", vec![Term::var("x"), Term::var("z")]);
42 let lives_in_tokyo = TLExpr::pred("LivesIn", vec![Term::var("z"), Term::constant("Tokyo")]);
43 let and_expr = TLExpr::and(friend_pred2, lives_in_tokyo);
44 let exists_friend_tokyo = TLExpr::exists("z", "Person", and_expr);
45
46 match compile_to_einsum_with_context(&exists_friend_tokyo, &mut ctx.clone()) {
47 Ok(graph) => {
48 println!(" Compiled successfully!");
49 println!(" Tensors: {}", graph.tensors.len());
50 println!(" Nodes: {}", graph.nodes.len());
51 for (i, tensor) in graph.tensors.iter().enumerate() {
52 println!(" Tensor {}: {}", i, tensor);
53 }
54 println!();
55 }
56 Err(e) => println!(" Compilation error: {}\n", e),
57 }
58
59 // Example 3: Nested quantifiers
60 // ∃y ∈ City. ∃z ∈ Person. (LivesIn(z, y) ∧ Friend(x, z))
61 // "There exists a city y and a person z such that z lives in y and is a friend of x"
62 println!("Example 3: ∃y ∈ City. ∃z ∈ Person. (LivesIn(z, y) ∧ Friend(x, z))");
63 println!(" 'For each person x, check if they have a friend living somewhere'");
64
65 let lives_in = TLExpr::pred("LivesIn", vec![Term::var("z"), Term::var("y")]);
66 let friend = TLExpr::pred("Friend", vec![Term::var("x"), Term::var("z")]);
67 let inner_and = TLExpr::and(lives_in, friend);
68 let exists_z = TLExpr::exists("z", "Person", inner_and);
69 let exists_y_z = TLExpr::exists("y", "City", exists_z);
70
71 match compile_to_einsum_with_context(&exists_y_z, &mut ctx.clone()) {
72 Ok(graph) => {
73 println!(" Compiled successfully!");
74 println!(" Tensors: {}", graph.tensors.len());
75 println!(" Nodes: {}", graph.nodes.len());
76 println!(" This demonstrates reduction over multiple axes:");
77 for (i, node) in graph.nodes.iter().enumerate() {
78 println!(" Node {}: op = {:?}", i, node.op);
79 }
80 println!();
81 }
82 Err(e) => println!(" Compilation error: {}\n", e),
83 }
84
85 println!("=== Compilation Complete ===");
86 println!("\nNote: These examples demonstrate how existential quantifiers");
87 println!("compile to tensor reductions. The actual tensor execution would");
88 println!("happen with a backend like SciRS2.");
89}examples/02_scirs2_execution/main.rs (line 19)
15fn main() -> anyhow::Result<()> {
16 println!("=== Tensorlogic + SciRS2: End-to-End Execution ===\n");
17
18 // 1. Define logic rule: Parent(x, y) → Ancestor(x, y)
19 let parent = TLExpr::pred("Parent", vec![Term::var("x"), Term::var("y")]);
20 let ancestor = TLExpr::pred("Ancestor", vec![Term::var("x"), Term::var("y")]);
21 let rule = TLExpr::imply(parent.clone(), ancestor.clone());
22
23 println!("Logic Rule: Parent(x, y) → Ancestor(x, y)");
24 println!("Interpretation: If Parent(x,y) holds, then Ancestor(x,y) should hold\n");
25
26 // 2. Compile to einsum graph
27 println!("Compiling to tensor graph...");
28 let graph = compile_to_einsum(&rule)?;
29 println!(" Tensors: {}", graph.tensors.len());
30 println!(" Nodes: {}", graph.nodes.len());
31
32 for (idx, tensor_name) in graph.tensors.iter().enumerate() {
33 println!(" Tensor {}: {}", idx, tensor_name);
34 }
35
36 for (idx, node) in graph.nodes.iter().enumerate() {
37 println!(" Node {}: {:?} (inputs: {:?})", idx, node.op, node.inputs);
38 }
39 println!();
40
41 // 3. Create SciRS2 executor and input tensors
42 println!("Creating SciRS2 executor...");
43 let mut executor = Scirs2Exec::new();
44
45 // Create a 3x3 Parent relation tensor (3 people, 3 people)
46 // Parent[i,j] = 1.0 if person i is parent of person j
47 let parent_data = vec![
48 0.0, 1.0, 1.0, // Person 0 is parent of 1, 2
49 0.0, 0.0, 0.0, // Person 1 has no children
50 0.0, 0.0, 0.0, // Person 2 has no children
51 ];
52
53 let parent_tensor = Scirs2Exec::from_vec(parent_data, vec![3, 3])?;
54 println!("Parent tensor shape: {:?}", parent_tensor.shape());
55 println!("Parent tensor:\n{:?}\n", parent_tensor);
56
57 // Create expected Ancestor tensor (also 3x3, same as Parent for this simple case)
58 let ancestor_data = vec![
59 0.0, 1.0, 1.0, // Person 0 is ancestor of 1, 2
60 0.0, 0.0, 0.0, // Person 1 has no descendants
61 0.0, 0.0, 0.0, // Person 2 has no descendants
62 ];
63
64 let ancestor_tensor = Scirs2Exec::from_vec(ancestor_data, vec![3, 3])?;
65 println!(
66 "Expected Ancestor tensor shape: {:?}",
67 ancestor_tensor.shape()
68 );
69 println!("Expected Ancestor tensor:\n{:?}\n", ancestor_tensor);
70
71 // Add tensors to executor storage using dynamic names from compiled graph
72 executor.add_tensor(graph.tensors[0].clone(), parent_tensor);
73 executor.add_tensor(graph.tensors[1].clone(), ancestor_tensor);
74
75 // 4. Execute the graph
76 println!("Executing forward pass...");
77 let output = executor.forward(&graph)?;
78 println!("Output tensor shape: {:?}", output.shape());
79 println!("Output tensor (constraint violation):\n{:?}\n", output);
80
81 // 5. Interpret results
82 println!("=== Interpretation ===");
83 println!("The output tensor represents constraint violations (via ReLU(Ancestor - Parent)).");
84 println!(" - Values near 0: rule satisfied (Parent implies Ancestor)");
85 println!(" - Positive values: violations (Parent holds but Ancestor doesn't)\n");
86
87 // Example 2: Test element-wise operations
88 println!("=== Testing SciRS2 Element-wise Operations ===\n");
89
90 let test_data = vec![-2.0, -1.0, 0.0, 1.0, 2.0];
91 let test_tensor = Scirs2Exec::from_vec(test_data, vec![5])?;
92
93 println!("Input: {:?}", test_tensor);
94
95 let relu_result = executor.elem_op(tensorlogic_infer::ElemOp::Relu, &test_tensor)?;
96 println!("ReLU: {:?}", relu_result);
97
98 let sigmoid_result = executor.elem_op(tensorlogic_infer::ElemOp::Sigmoid, &test_tensor)?;
99 println!("Sigmoid: {:?}", sigmoid_result);
100
101 let one_minus_result = executor.elem_op(tensorlogic_infer::ElemOp::OneMinus, &test_tensor)?;
102 println!("OneMinus: {:?}\n", one_minus_result);
103
104 // Example 3: Test reduction operations
105 println!("=== Testing SciRS2 Reduction Operations ===\n");
106
107 let matrix_data = vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
108 let matrix = Scirs2Exec::from_vec(matrix_data, vec![2, 3])?;
109
110 println!("Input matrix (2x3):\n{:?}\n", matrix);
111
112 let sum_axis0 = executor.reduce(tensorlogic_infer::ReduceOp::Sum, &matrix, &[0])?;
113 println!("Sum over axis 0: {:?}", sum_axis0);
114
115 let sum_axis1 = executor.reduce(tensorlogic_infer::ReduceOp::Sum, &matrix, &[1])?;
116 println!("Sum over axis 1: {:?}", sum_axis1);
117
118 let max_axis0 = executor.reduce(tensorlogic_infer::ReduceOp::Max, &matrix, &[0])?;
119 println!("Max over axis 0: {:?}", max_axis0);
120
121 let mean_axis1 = executor.reduce(tensorlogic_infer::ReduceOp::Mean, &matrix, &[1])?;
122 println!("Mean over axis 1: {:?}\n", mean_axis1);
123
124 println!("=== Execution Complete ===");
125 println!("\nThis demonstrates the full pipeline:");
126 println!(" Logic → IR → Einsum Graph → SciRS2 Execution → Results");
127
128 Ok(())
129}Sourcepub fn constant(name: impl Into<String>) -> Term
pub fn constant(name: impl Into<String>) -> Term
Examples found in repository?
examples/01_exists_reduce/main.rs (line 42)
4fn main() {
5 println!("=== Tensorlogic Example: Exists Quantifier with Reduction ===\n");
6
7 // Define domains
8 let mut ctx = CompilerContext::new();
9 ctx.add_domain("Person", 10);
10 ctx.add_domain("City", 5);
11
12 println!("Domains defined:");
13 println!(" Person: cardinality = 10");
14 println!(" City: cardinality = 5\n");
15
16 // Example 1: Basic exists quantifier
17 // ∃z ∈ Person. Friend(x, z)
18 // "There exists a person z who is a friend of x"
19 println!("Example 1: ∃z ∈ Person. Friend(x, z)");
20 println!(" 'For each person x, check if there exists a friend z'");
21
22 let friend_pred = TLExpr::pred("Friend", vec![Term::var("x"), Term::var("z")]);
23 let exists_friend = TLExpr::exists("z", "Person", friend_pred);
24
25 match compile_to_einsum_with_context(&exists_friend, &mut ctx.clone()) {
26 Ok(graph) => {
27 println!(" Compiled successfully!");
28 println!(" Tensors: {}", graph.tensors.len());
29 println!(" Nodes: {}", graph.nodes.len());
30 println!(" Graph tensors: {:?}\n", graph.tensors);
31 }
32 Err(e) => println!(" Compilation error: {}\n", e),
33 }
34
35 // Example 2: Exists with conjunction
36 // ∃z ∈ Person. (Friend(x, z) ∧ LivesIn(z, "Tokyo"))
37 // "There exists a person z who is a friend of x AND lives in Tokyo"
38 println!("Example 2: ∃z ∈ Person. (Friend(x, z) ∧ LivesIn(z, Tokyo))");
39 println!(" 'For each person x, check if they have a friend in Tokyo'");
40
41 let friend_pred2 = TLExpr::pred("Friend", vec![Term::var("x"), Term::var("z")]);
42 let lives_in_tokyo = TLExpr::pred("LivesIn", vec![Term::var("z"), Term::constant("Tokyo")]);
43 let and_expr = TLExpr::and(friend_pred2, lives_in_tokyo);
44 let exists_friend_tokyo = TLExpr::exists("z", "Person", and_expr);
45
46 match compile_to_einsum_with_context(&exists_friend_tokyo, &mut ctx.clone()) {
47 Ok(graph) => {
48 println!(" Compiled successfully!");
49 println!(" Tensors: {}", graph.tensors.len());
50 println!(" Nodes: {}", graph.nodes.len());
51 for (i, tensor) in graph.tensors.iter().enumerate() {
52 println!(" Tensor {}: {}", i, tensor);
53 }
54 println!();
55 }
56 Err(e) => println!(" Compilation error: {}\n", e),
57 }
58
59 // Example 3: Nested quantifiers
60 // ∃y ∈ City. ∃z ∈ Person. (LivesIn(z, y) ∧ Friend(x, z))
61 // "There exists a city y and a person z such that z lives in y and is a friend of x"
62 println!("Example 3: ∃y ∈ City. ∃z ∈ Person. (LivesIn(z, y) ∧ Friend(x, z))");
63 println!(" 'For each person x, check if they have a friend living somewhere'");
64
65 let lives_in = TLExpr::pred("LivesIn", vec![Term::var("z"), Term::var("y")]);
66 let friend = TLExpr::pred("Friend", vec![Term::var("x"), Term::var("z")]);
67 let inner_and = TLExpr::and(lives_in, friend);
68 let exists_z = TLExpr::exists("z", "Person", inner_and);
69 let exists_y_z = TLExpr::exists("y", "City", exists_z);
70
71 match compile_to_einsum_with_context(&exists_y_z, &mut ctx.clone()) {
72 Ok(graph) => {
73 println!(" Compiled successfully!");
74 println!(" Tensors: {}", graph.tensors.len());
75 println!(" Nodes: {}", graph.nodes.len());
76 println!(" This demonstrates reduction over multiple axes:");
77 for (i, node) in graph.nodes.iter().enumerate() {
78 println!(" Node {}: op = {:?}", i, node.op);
79 }
80 println!();
81 }
82 Err(e) => println!(" Compilation error: {}\n", e),
83 }
84
85 println!("=== Compilation Complete ===");
86 println!("\nNote: These examples demonstrate how existential quantifiers");
87 println!("compile to tensor reductions. The actual tensor execution would");
88 println!("happen with a backend like SciRS2.");
89}Sourcepub fn typed_var(name: impl Into<String>, type_name: impl Into<String>) -> Term
pub fn typed_var(name: impl Into<String>, type_name: impl Into<String>) -> Term
Create a typed variable
Sourcepub fn typed_const(
name: impl Into<String>,
type_name: impl Into<String>,
) -> Term
pub fn typed_const( name: impl Into<String>, type_name: impl Into<String>, ) -> Term
Create a typed constant
Sourcepub fn with_type(self, type_name: impl Into<String>) -> Term
pub fn with_type(self, type_name: impl Into<String>) -> Term
Attach a type annotation to an existing term
pub fn is_var(&self) -> bool
pub fn is_const(&self) -> bool
pub fn name(&self) -> &str
Sourcepub fn get_type(&self) -> Option<&TypeAnnotation>
pub fn get_type(&self) -> Option<&TypeAnnotation>
Get the type annotation if present
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Term
impl<'de> Deserialize<'de> for Term
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Term, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Term, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Term
Source§impl Serialize for Term
impl Serialize for Term
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Term
Auto Trait Implementations§
impl Freeze for Term
impl RefUnwindSafe for Term
impl Send for Term
impl Sync for Term
impl Unpin for Term
impl UnsafeUnpin for Term
impl UnwindSafe for Term
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> Node for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.