pub struct LastSubject(pub Subject);Expand description
Newtype wrapper for “last wins” combination strategy.
When combining two LastSubject instances, the second subject is returned and the first is discarded. This is useful for scenarios where you want the most recent subject to take precedence.
§Semigroup Laws
This satisfies associativity trivially: last(last(a, b), c) = last(a, last(b, c)) = c
§Examples
use pattern_core::{Subject, Symbol, Combinable, LastSubject};
use std::collections::HashSet;
let s1 = LastSubject(Subject {
identity: Symbol("alice".to_string()),
labels: HashSet::new(),
properties: Default::default(),
});
let s2 = LastSubject(Subject {
identity: Symbol("bob".to_string()),
labels: HashSet::new(),
properties: Default::default(),
});
// Last wins - s1 is the last argument, so it wins
let result = s2.combine(s1);
assert_eq!(result.0.identity.0, "alice");Tuple Fields§
§0: SubjectTrait Implementations§
Source§impl Clone for LastSubject
impl Clone for LastSubject
Source§fn clone(&self) -> LastSubject
fn clone(&self) -> LastSubject
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 LastSubject
impl Combinable for LastSubject
Source§impl PartialEq for LastSubject
impl PartialEq for LastSubject
impl StructuralPartialEq for LastSubject
Auto Trait Implementations§
impl Freeze for LastSubject
impl RefUnwindSafe for LastSubject
impl Send for LastSubject
impl Sync for LastSubject
impl Unpin for LastSubject
impl UnsafeUnpin for LastSubject
impl UnwindSafe for LastSubject
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