MCPcopy Create free account
hub / github.com/LaBatata101/sith-language-server / as_binary_operator

Method as_binary_operator

crates/sith_python_parser/src/token.rs:486–503  ·  view source on GitHub ↗

Returns the binary [`Operator`] that corresponds to the current token, if it's a binary operator, otherwise return [None]. Use [`as_augmented_assign_operator`] to match against an augmented assignment token. [`as_augmented_assign_operator`]: TokenKind::as_augmented_assign_operator

(self)

Source from the content-addressed store, hash-verified

484 ///
485 /// [`as_augmented_assign_operator`]: TokenKind::as_augmented_assign_operator
486 pub(crate) const fn as_binary_operator(self) -> Option<Operator> {
487 Some(match self {
488 TokenKind::Plus => Operator::Add,
489 TokenKind::Minus => Operator::Sub,
490 TokenKind::Star => Operator::Mult,
491 TokenKind::At => Operator::MatMult,
492 TokenKind::DoubleStar => Operator::Pow,
493 TokenKind::Slash => Operator::Div,
494 TokenKind::DoubleSlash => Operator::FloorDiv,
495 TokenKind::Percent => Operator::Mod,
496 TokenKind::Amper => Operator::BitAnd,
497 TokenKind::Vbar => Operator::BitOr,
498 TokenKind::CircumFlex => Operator::BitXor,
499 TokenKind::LeftShift => Operator::LShift,
500 TokenKind::RightShift => Operator::RShift,
501 _ => return None,
502 })
503 }
504
505 /// Returns the [`Operator`] that corresponds to this token kind, if it is
506 /// an augmented assignment operator, or [`None`] otherwise.

Callers 1

try_from_tokensMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected