Skip to content

Commit 078fbb0

Browse files
committed
support dyn keyword(2506)
1 parent 5025a53 commit 078fbb0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/types.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,15 @@ impl Rewrite for ast::TraitRef {
616616
impl Rewrite for ast::Ty {
617617
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
618618
match self.node {
619-
ast::TyKind::TraitObject(ref bounds, ..) => bounds.rewrite(context, shape),
619+
ast::TyKind::TraitObject(ref bounds, tobj_syntax) => {
620+
let res = bounds.rewrite(context, shape)?;
621+
// we have to consider 'dyn' keyword is used or not!!!
622+
if tobj_syntax == ast::TraitObjectSyntax::Dyn {
623+
Some(format!("dyn {}", res))
624+
} else {
625+
Some(res)
626+
}
627+
}
620628
ast::TyKind::Ptr(ref mt) => {
621629
let prefix = match mt.mutbl {
622630
Mutability::Mutable => "*mut ",

0 commit comments

Comments
 (0)