Codebase list golang-github-vbauerster-mpb / 0a1ff47 decor / any.go
0a1ff47

Tree @0a1ff47 (Download .tar.gz)

any.go @0a1ff47raw · history · blame

package decor

var _ Decorator = any{}

// Any decorator.
// Converts DecorFunc into Decorator.
//
//	`fn` DecorFunc callback
//	`wcc` optional WC config
func Any(fn DecorFunc, wcc ...WC) Decorator {
	return any{initWC(wcc...), fn}
}

type any struct {
	WC
	fn DecorFunc
}

func (d any) Decor(s Statistics) (string, int) {
	return d.Format(d.fn(s))
}