Codebase list golang-github-vbauerster-mpb / 8feb9fa decor / any.go
8feb9fa

Tree @8feb9fa (Download .tar.gz)

any.go @8feb9faraw · 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))
}