ide_db::syntax_helpers::format_string_exprs

Function parse_format_exprs

source
pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()>
Expand description

Parser for a format-like string. It is more allowing in terms of string contents, as we expect variable placeholders to be filled with expressions.

Splits a format string that may contain expressions like

assert_eq!(parse_format_exprs("{ident} {} {expr + 42} ").unwrap(), ("{ident} {} {} ".to_owned(), vec![Arg::Placeholder, Arg::Expr("expr + 42".to_owned())]));