Function parse_expression

Source
pub fn parse_expression(source: &str, path: &str) -> Result<Expr, ParseError>
๐Ÿ‘ŽDeprecated: Use ast::Expr::parse from rustpython_parser::Parse trait.
Expand description

Parses a single Python expression.

This convenience function can be used to parse a single expression without having to specify the Mode or the location.

ยงExample

For example, parsing a single expression denoting the addition of two numbers:

use rustpython_parser as parser;
let expr = parser::parse_expression("1 + 2", "<embedded>");

assert!(expr.is_ok());