Skip to main content

validate_literal

Function validate_literal 

Source
pub fn validate_literal(lit: &Literal) -> Result<()>
Expand description

Validates a syntax literal using the expression parser’s value rules.

Floating-point overflow produces infinity; unrepresentable integers are rejected.

§Errors

Returns Err for an unsupported literal kind or numeric suffix, a misplaced exponent sign, or a numeric value that cannot be parsed as its type.

  • Complexity: Includes literal-token cloning and value parsing for the token’s text.

§Examples

let literal: syn::Lit = syn::parse_str("42i32").unwrap();
cel_parser::validate_literal(&literal).unwrap();
let float: syn::Lit = syn::parse_str("1f64").unwrap();
cel_parser::validate_literal(&float).unwrap();