Small changes in str formatting
This commit is contained in:
parent
7c9e4e10bc
commit
caa13b3f95
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
use crate::{ast, utils::is_raw_identifier, AstNode, SourceFile, SyntaxKind, SyntaxToken};
|
use crate::{ast, utils::is_raw_identifier, AstNode, SourceFile, SyntaxKind, SyntaxToken};
|
||||||
|
|
||||||
use super::WhereClause;
|
|
||||||
|
|
||||||
/// While the parent module defines basic atomic "constructors", the `ext`
|
/// While the parent module defines basic atomic "constructors", the `ext`
|
||||||
/// module defines shortcuts for common things.
|
/// module defines shortcuts for common things.
|
||||||
///
|
///
|
||||||
@ -160,50 +158,47 @@ fn ty_from_text(text: &str) -> ast::Type {
|
|||||||
ast_from_text(&format!("type _T = {text};"))
|
ast_from_text(&format!("type _T = {text};"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Related goto [link](https://doc.rust-lang.org/reference/items/type-aliases.html)
|
/// Related goto [link](https://doc.rust-lang.org/reference/items/type-aliases.html)
|
||||||
Type Alias syntax is
|
/// Type Alias syntax is
|
||||||
|
///
|
||||||
```
|
/// ```
|
||||||
TypeAlias :
|
/// TypeAlias :
|
||||||
type IDENTIFIER GenericParams? ( : TypeParamBounds )? WhereClause? ( = Type WhereClause?)? ;
|
/// type IDENTIFIER GenericParams? ( : TypeParamBounds )? WhereClause? ( = Type WhereClause?)? ;
|
||||||
```
|
/// ```
|
||||||
|
///
|
||||||
FIXME : ident should be of type ast::Ident
|
/// FIXME : ident should be of type ast::Ident
|
||||||
*/
|
|
||||||
pub fn ty_alias(
|
pub fn ty_alias(
|
||||||
ident: String,
|
ident: &str,
|
||||||
generic_param_list: Option<ast::GenericParamList>,
|
generic_param_list: Option<ast::GenericParamList>,
|
||||||
type_param_bounds: Option<ast::TypeParam>,
|
type_param_bounds: Option<ast::TypeParam>,
|
||||||
where_clause: Option<WhereClause>,
|
where_clause: Option<ast::WhereClause>,
|
||||||
assignment: Option<(ast::Type, Option<ast::WhereClause>)>,
|
assignment: Option<(ast::Type, Option<ast::WhereClause>)>,
|
||||||
) -> ast::TypeAlias {
|
) -> ast::TypeAlias {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
s.push_str(format!("type {}", ident.as_str()).as_str());
|
s.push_str(&format!("type {}", ident));
|
||||||
|
|
||||||
if let Some(list) = generic_param_list {
|
if let Some(list) = generic_param_list {
|
||||||
s.push_str(list.to_string().as_str());
|
s.push_str(&list.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(list) = type_param_bounds {
|
if let Some(list) = type_param_bounds {
|
||||||
s.push_str(format!(" : {}", list.to_string().as_str()).as_str());
|
s.push_str(&format!(" : {}", &list.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(cl) = where_clause {
|
if let Some(cl) = where_clause {
|
||||||
s.push_str(format!(" {}", cl.to_string().as_str()).as_str());
|
s.push_str(&format!(" {}", &cl.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(exp) = assignment {
|
if let Some(exp) = assignment {
|
||||||
if let Some(cl) = exp.1 {
|
if let Some(cl) = exp.1 {
|
||||||
s.push_str(
|
s.push_str(&format!("= {} {}", &exp.0.to_string(), &cl.to_string()));
|
||||||
format!("= {} {}", exp.0.to_string().as_str(), cl.to_string().as_str()).as_str(),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
s.push_str(format!("= {}", exp.0.to_string().as_str()).as_str());
|
s.push_str(&format!("= {}", &exp.0.to_string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.push_str(";");
|
s.push_str(";");
|
||||||
ast_from_text(s.as_str())
|
ast_from_text(&s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assoc_item_list() -> ast::AssocItemList {
|
pub fn assoc_item_list() -> ast::AssocItemList {
|
||||||
|
Loading…
Reference in New Issue
Block a user