pub struct PredicateCmp<A, B, Same = Enable, Different = Disable>(/* private fields */)
where
A: PredicateOp,
B: PredicateOp,
Same: PredicateOp,
Different: PredicateOp;Expand description
Predicate that compares type A with type B at runtime.
Acts like Same when A == B (=Enable), and Differentwhen A != B (=Disable).
This enables distinguishing between different predicate flags at compile time through
runtime type checks (which are usually optimized away by the compiler).
§Examples
use unsynn::*;
//use unsynn::predicates::*;
unsynn! {
predicatetrait Context;
predicateflag InExpr for Context;
predicateflag InStmt for Context;
// Only accepts InExpr, rejects InStmt
struct OnlyInExpr<C: Context> {
_guard: PredicateCmp<C, InExpr>,
content: Ident,
}
// Accepts InExpr but NOT InStmt
struct ExprButNotStmt<C: Context> {
_guard: AllOf<PredicateCmp<C, InExpr>, Not<PredicateCmp<C, InStmt>>>,
content: Ident,
}
}Implementations§
Source§impl<A, B, Same, Different> PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> PredicateCmp<A, B, Same, Different>
Sourcepub const fn new() -> PredicateCmp<A, B, Same, Different>
pub const fn new() -> PredicateCmp<A, B, Same, Different>
Create a new PredicateCmp instance.
This is primarily useful for testing or when you need to manually construct the predicate.
Trait Implementations§
Source§impl<A, B, Same, Different> Clone for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> Clone for PredicateCmp<A, B, Same, Different>
Source§fn clone(&self) -> PredicateCmp<A, B, Same, Different>
fn clone(&self) -> PredicateCmp<A, B, Same, Different>
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<A, B, Same, Different> Debug for PredicateCmp<A, B, Same, Different>where
A: Debug + PredicateOp,
B: Debug + PredicateOp,
Same: Debug + PredicateOp,
Different: Debug + PredicateOp,
impl<A, B, Same, Different> Debug for PredicateCmp<A, B, Same, Different>where
A: Debug + PredicateOp,
B: Debug + PredicateOp,
Same: Debug + PredicateOp,
Different: Debug + PredicateOp,
Source§impl<A, B, Same, Different> Default for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> Default for PredicateCmp<A, B, Same, Different>
Source§fn default() -> PredicateCmp<A, B, Same, Different>
fn default() -> PredicateCmp<A, B, Same, Different>
Returns the “default value” for a type. Read more
Source§impl<A, B, Same, Different> Parser for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> Parser for PredicateCmp<A, B, Same, Different>
Source§fn parser(
tokens: &mut TokenIter,
) -> Result<PredicateCmp<A, B, Same, Different>, Error>
fn parser( tokens: &mut TokenIter, ) -> Result<PredicateCmp<A, B, Same, Different>, Error>
The actual parsing function that must be implemented. This mutates the
tokens
iterator directly. It should not be called from user code except for implementing
parsers itself and then only when the rules below are followed. Read moreSource§impl<A, B, Same, Different> ToTokens for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> ToTokens for PredicateCmp<A, B, Same, Different>
Source§fn to_tokens(&self, _tokens: &mut TokenStream)
fn to_tokens(&self, _tokens: &mut TokenStream)
Source§fn into_token_iter(self) -> TokenIter ⓘwhere
Self: Sized,
fn into_token_iter(self) -> TokenIter ⓘwhere
Self: Sized,
Convert
self into a TokenIter object.Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Convert
&self into a TokenStream object.Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
Convert
self into a TokenStream object.impl<A, B, Same, Different> Copy for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> PredicateOp for PredicateCmp<A, B, Same, Different>
Auto Trait Implementations§
impl<A, B, Same, Different> Freeze for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> RefUnwindSafe for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> Send for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> Sync for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> Unpin for PredicateCmp<A, B, Same, Different>
impl<A, B, Same, Different> UnwindSafe for PredicateCmp<A, B, Same, Different>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DynamicTokens for T
impl<T> DynamicTokens for T
Source§impl<T> Parse for Twhere
T: Parser,
impl<T> Parse for Twhere
T: Parser,
Source§fn parse(tokens: &mut TokenIter) -> Result<Self, Error>
fn parse(tokens: &mut TokenIter) -> Result<Self, Error>
This is the user facing API to parse grammatical entities. Calls a
parser() within a
transaction. Commits changes on success and returns the parsed value. Read more