pub struct SharedSpecification<T: ?Sized> { /* private fields */ }Expand description
An explicitly type-erased specification that can be shared across threads.
The Send + Sync bounds belong to the erased trait object and the
constructor, so sharing is an explicit API choice. The ordinary
Specification trait remains usable for single-threaded rules that do
not satisfy those bounds.
A captured non-thread-safe value is rejected at the shared boundary:
ⓘ
use std::rc::Rc;
use specification_core::SharedSpecification;
let state = Rc::new(1_u8);
let _rule = SharedSpecification::new(move |_: &u8| *state == 1);Implementations§
Trait Implementations§
Source§fn is_satisfied_by(&self, candidate: &T) -> bool
fn is_satisfied_by(&self, candidate: &T) -> bool
Returns whether
candidate satisfies this rule.Source§fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
fn and<Other>(self, other: Other) -> And<Self, Other>where
Self: Sized,
Other: Specification<T>,
Combines this rule with
other using short-circuiting logical AND. Read moreAuto Trait Implementations§
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