pub struct EmptySubject(pub Subject);Expand description
Newtype wrapper for “empty” combination strategy that creates anonymous subjects.
When combining two EmptySubject instances, the result is always an anonymous subject with no labels or properties. This serves as the identity element for a Monoid-like structure.
§Semigroup Laws
This satisfies associativity trivially: empty(empty(a, b), c) = empty(a, empty(b, c)) = empty
§Monoid Laws
When used with Default, this provides monoid identity:
- Left identity: empty.combine(s) = empty
- Right identity: s.combine(empty) = empty
§Examples
use pattern_core::{Subject, Symbol, Combinable, EmptySubject};
use std::collections::HashSet;
let s1 = EmptySubject(Subject {
identity: Symbol("alice".to_string()),
labels: {
let mut s = HashSet::new();
s.insert("Person".to_string());
s
},
properties: Default::default(),
});
let empty = EmptySubject(Subject {
identity: Symbol("_".to_string()),
labels: HashSet::new(),
properties: Default::default(),
});
// Always returns empty (anonymous)
let result = s1.combine(empty);
assert_eq!(result.0.identity.0, "_");
assert!(result.0.labels.is_empty());Tuple Fields§
§0: SubjectTrait Implementations§
Source§impl Clone for EmptySubject
impl Clone for EmptySubject
Source§fn clone(&self) -> EmptySubject
fn clone(&self) -> EmptySubject
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Combinable for EmptySubject
impl Combinable for EmptySubject
Source§impl Default for EmptySubject
impl Default for EmptySubject
Source§impl PartialEq for EmptySubject
impl PartialEq for EmptySubject
impl StructuralPartialEq for EmptySubject
Auto Trait Implementations§
impl Freeze for EmptySubject
impl RefUnwindSafe for EmptySubject
impl Send for EmptySubject
impl Sync for EmptySubject
impl Unpin for EmptySubject
impl UnsafeUnpin for EmptySubject
impl UnwindSafe for EmptySubject
Blanket Implementations§
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