pub struct OperDef {
pub fixity: Fixity,
pub prec: i64,
pub assoc: Assoc,
pub args: Vec<OperArg>,
pub rename_to: Option<Term>,
pub embed_fixity: bool,
}Expand description
Defines a single operator, including its fixity, precedence, associativity, and optional additional parameters.
Each operator definition describes how the parser should treat a symbol syntactically, including its argument behavior and binding strength.
§Field Rules
precmust be0forFixity::Fun.assocmust be:Assoc::NoneforFixity::Fun,Assoc::RightforFixity::Prefix,Assoc::LeftforFixity::Postfix.
Fields§
§fixity: FixityOperator fixity (function, prefix, infix, or postfix).
prec: i64Operator precedence (0–1200).
Higher numbers indicate tighter binding.
Must be 0 for Fixity::Fun.
assoc: AssocOperator associativity (depends on fixity).
args: Vec<OperArg>Optional extra arguments beyond the operator’s required operands.
rename_to: Option<Term>Optional renaming target (atom term).
embed_fixity: boolWhether this operator’s fixity should be embedded in generated term.
Implementations§
Source§impl OperDef
impl OperDef
Sourcepub fn required_arity(fixity: Fixity) -> usize
pub fn required_arity(fixity: Fixity) -> usize
Returns the number of required operands for a given Fixity.
Fixity::Fun→0Fixity::Prefix→1Fixity::Infix→2Fixity::Postfix→1
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OperDef
impl RefUnwindSafe for OperDef
impl Send for OperDef
impl Sync for OperDef
impl Unpin for OperDef
impl UnwindSafe for OperDef
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