MCPcopy Create free account
hub / github.com/astral-sh/ruff / try_into_expression

Method try_into_expression

crates/ruff_python_parser/src/lib.rs:513–523  ·  view source on GitHub ↗

Attempts to convert the [`Parsed `] into a [`Parsed `]. This method checks if the `syntax` field of the output is a [`Mod::Expression`]. If it is, the method returns [`Some(Parsed )`] with the contained expression. Otherwise, it returns [`None`]. [`Some(Parsed )`]: Some

(self)

Source from the content-addressed store, hash-verified

511 ///
512 /// [`Some(Parsed<ModExpression>)`]: Some
513 pub fn try_into_expression(self) -> Option<Parsed<ModExpression>> {
514 match self.syntax {
515 Mod::Module(_) => None,
516 Mod::Expression(expression) => Some(Parsed {
517 syntax: expression,
518 tokens: self.tokens,
519 errors: self.errors,
520 unsupported_syntax_errors: self.unsupported_syntax_errors,
521 }),
522 }
523 }
524}
525
526impl Parsed<ModModule> {

Callers 3

parse_expressionFunction · 0.80
parse_expression_rangeFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected