Skip to content

Commit

Permalink
julefmt: add support for constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Apr 25, 2024
1 parent 4e180f3 commit 1aee297
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/format.jule
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,22 @@ impl Formatter {
}
}

fn generics(&self, &g: []&ast::GenericDecl) {
fn generics(&self, mut &g: []&ast::GenericDecl) {
if g.len == 0 {
ret
}
self.write("[")
for i, t in g {
for (i, mut t) in g {
self.write(t.ident)
if t.constraint != nil {
self.write(": ")
for (j, mut c) in t.constraint.mask {
self.format_type(c)
if t.constraint.mask.len - j > 1 {
self.write(" | ")
}
}
}
if i+1 < g.len {
self.write(", ")
}
Expand Down

0 comments on commit 1aee297

Please sign in to comment.