Function rustpython_parser::parse_expression_starts_at
source · pub fn parse_expression_starts_at(
source: &str,
path: &str,
offset: TextSize
) -> Result<Expr, ParseError>
👎Deprecated: Use ast::Expr::parse_starts_at from rustpython_parser::Parse trait.
Expand description
Parses a Python expression from a given location.
This function allows to specify the location of the expression in the source code, other than
that, it behaves exactly like parse_expression
.
§Example
Parsing a single expression denoting the addition of two numbers, but this time specifying a different, somewhat silly, location:
use rustpython_parser::{text_size::TextSize, parse_expression_starts_at};
let expr = parse_expression_starts_at("1 + 2", "<embedded>", TextSize::from(400));
assert!(expr.is_ok());