Codebase list golang-github-vbauerster-mpb / lintian-fixes/main decor / any.go
lintian-fixes/main

Tree @lintian-fixes/main (Download .tar.gz)

any.go @lintian-fixes/mainraw · 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))
}