Codebase list golang-github-vbauerster-mpb / 4365b13
refactoring Any no need for pointer receiver Vladimir Bauer 2 years ago
1 changed file(s) with 6 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
00 package decor
11
2 var _ Decorator = (*any)(nil)
2 var _ Decorator = any{}
33
4 // Any decorator displays text, that can be changed during decorator's
5 // lifetime via provided DecorFunc.
4 // Any decorator.
5 // Converts DecorFunc into Decorator.
66 //
77 // `fn` DecorFunc callback
8 //
98 // `wcc` optional WC config
109 func Any(fn DecorFunc, wcc ...WC) Decorator {
11 return &any{initWC(wcc...), fn}
10 return any{initWC(wcc...), fn}
1211 }
1312
1413 type any struct {
1615 fn DecorFunc
1716 }
1817
19 func (d *any) Decor(s Statistics) string {
20 return d.FormatMsg(d.fn(s))
18 func (d any) Decor(s Statistics) (string, int) {
19 return d.Format(d.fn(s))
2120 }