Skip to main content

parse_expression_detailed

Function parse_expression_detailed 

Source
pub fn parse_expression_detailed(s: &str) -> Result<Expression, ExprError>
Expand description

Parse an expression string, reporting why it is not one.

The counterpart to parse_expression, for callers that put the failure in front of an author. Accepts exactly the same strings.

§Examples

use rite_model::expression::{parse_expression_detailed, ExprError, RefType};

let err = parse_expression_detailed("${nonsense.x}").unwrap_err();
assert!(matches!(err, ExprError::UnknownNamespace { .. }));

let err = parse_expression_detailed("${paramm.region}").unwrap_err();
assert_eq!(err.to_string(), "unknown namespace 'paramm': did you mean 'param'?");

§Errors

Returns the ExprError naming the first thing that did not parse.