@@ -11,15 +11,12 @@ pub enum Arg {
1111 Expr ( String ) ,
1212}
1313
14- /**
15- Add placeholders like `$1` and `$2` in place of [`Arg::Placeholder`],
16- and unwraps the [`Arg::Ident`] and [`Arg::Expr`] enums.
17- ```rust
18- # use ide_db::syntax_helpers::format_string_exprs::*;
19- assert_eq!(with_placeholders(vec![Arg::Ident("ident".to_owned()), Arg::Placeholder, Arg::Expr("expr + 2".to_owned())]), vec!["ident".to_owned(), "$1".to_owned(), "expr + 2".to_owned()])
20- ```
21- */
22-
14+ /// Add placeholders like `$1` and `$2` in place of [`Arg::Placeholder`],
15+ /// and unwraps the [`Arg::Ident`] and [`Arg::Expr`] enums.
16+ /// ```rust
17+ /// # use ide_db::syntax_helpers::format_string_exprs::*;
18+ /// assert_eq!(with_placeholders(vec![Arg::Ident("ident".to_owned()), Arg::Placeholder, Arg::Expr("expr + 2".to_owned())]), vec!["ident".to_owned(), "$1".to_owned(), "expr + 2".to_owned()])
19+ /// ```
2320pub fn with_placeholders ( args : Vec < Arg > ) -> Vec < String > {
2421 let mut placeholder_id = 1 ;
2522 args. into_iter ( )
@@ -34,18 +31,15 @@ pub fn with_placeholders(args: Vec<Arg>) -> Vec<String> {
3431 . collect ( )
3532}
3633
37- /**
38- Parser for a format-like string. It is more allowing in terms of string contents,
39- as we expect variable placeholders to be filled with expressions.
40-
41- Built for completions and assists, and escapes `\` and `$` in output.
42- (See the comments on `get_receiver_text()` for detail.)
43- Splits a format string that may contain expressions
44- like
45- ```rust
46- assert_eq!(parse("{ident} {} {expr + 42} ").unwrap(), ("{} {} {}", vec![Arg::Ident("ident"), Arg::Placeholder, Arg::Expr("expr + 42")]));
47- ```
48- */
34+ /// Parser for a format-like string. It is more allowing in terms of string contents,
35+ /// as we expect variable placeholders to be filled with expressions.
36+ ///
37+ /// Splits a format string that may contain expressions
38+ /// like
39+ /// ```rust
40+ /// # use ide_db::syntax_helpers::format_string_exprs::*;
41+ /// assert_eq!(parse_format_exprs("{ident} {} {expr + 42} ").unwrap(), ("{ident} {} {} ".to_owned(), vec![Arg::Placeholder, Arg::Expr("expr + 42".to_owned())]));
42+ /// ```
4943pub fn parse_format_exprs ( input : & str ) -> Result < ( String , Vec < Arg > ) , ( ) > {
5044 #[ derive( Debug , Clone , Copy , PartialEq ) ]
5145 enum State {
0 commit comments