#[non_exhaustive]pub enum OpSpec {
Show 13 variants
Op(OpKind),
OpWith(Op),
Compound(OpKind),
CompoundWith(Op),
Assign,
RefAssign,
Identity,
Borrow(BorrowKind),
Deref,
Await,
Template(TemplateId),
Extern(NameRef),
Intrinsic(NameRef),
}Expand description
What an operator token lowers to.
§Examples
use hir_lang::{Op, OpKind, Overflow};
use lower_lang::OpSpec;
let plus = OpSpec::Op(OpKind::Add); // language policy
let wrapping = OpSpec::OpWith(Op::new(OpKind::Add).with_overflow(Overflow::Wrap));
let plus_eq = OpSpec::Compound(OpKind::Add); // `+=`
assert_ne!(plus, wrapping);
assert_ne!(plus, plus_eq);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Op(OpKind)
An intrinsic op with the language’s policies (LangPolicy).
OpWith(Op)
An intrinsic op with exactly this policy ([semantics.ops] "/" = { op = "div", zero = "trap" }).
Compound(OpKind)
Compound assignment (+=) with the language’s policies.
CompoundWith(Op)
Compound assignment with exactly this policy.
Assign
Plain assignment (= as an operator).
RefAssign
Reference assignment (=&).
Identity
The operand itself (unary +).
Borrow(BorrowKind)
&x / &mut x as a prefix operator.
Deref
*x as a prefix operator.
Await
await x (prefix) or x.await (postfix).
Template(TemplateId)
A template whose expression holes receive the operands, in order
(&&, ||, ??, x++).
Extern(NameRef)
A call of a host function with the operands as arguments (Mox .
string concatenation).
Intrinsic(NameRef)
A named backend intrinsic applied to the operands.
Trait Implementations§
impl Copy for OpSpec
impl Eq for OpSpec
impl StructuralPartialEq for OpSpec
Auto Trait Implementations§
impl Freeze for OpSpec
impl RefUnwindSafe for OpSpec
impl Send for OpSpec
impl Sync for OpSpec
impl Unpin for OpSpec
impl UnsafeUnpin for OpSpec
impl UnwindSafe for OpSpec
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