Skip to content

Commit

Permalink
String panics if wrapped Fprint returns an error.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Feb 2, 2024
1 parent 7887d36 commit d6034bd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion stringify.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ type kidT[V any] struct {

// String returns a hierarchical tree diagram of the ordered CIDRs
// as string, just a wrapper for [Table.Fprint].
// If Fprint returns an error, String panics.
func (t *Table[V]) String() string {
t.init()
w := new(strings.Builder)
_ = t.Fprint(w)
if err := t.Fprint(w); err != nil {
panic(err)
}
return w.String()
}

Expand Down

0 comments on commit d6034bd

Please sign in to comment.