pub fn literal_expr(lit: &Literal) -> Result<Expr>Expand description
Converts one syntax literal into retained expression syntax without executing code.
Preserves the token’s source span and concrete numeric width using the same validation as expression parsing.
§Errors
Rejects unsupported literal kinds, invalid suffixes, and out-of-range values.
- Complexity: O(n) literal bytes.
§Examples
let token: syn::Lit = syn::parse_str("42i32")?;
assert!(matches!(cel_parser::literal_expr(&token)?,
cel_parser::Expr::Literal { value: cel_parser::Literal::I32(42), .. }));