Skip to content

Commit

Permalink
Reorder options.go
Browse files Browse the repository at this point in the history
  • Loading branch information
borodean committed Dec 26, 2021
1 parent 5c6f3c3 commit 030be85
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions options.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package asciitree

type sortOptions struct {
dirsFirst bool
}

// SortOption represents an option that can be provided to the Sort method.
type SortOption interface {
apply(*sortOptions)
}

type sortOptions struct {
dirsFirst bool
}

type dirsFirstOption bool

func (d dirsFirstOption) apply(opts *sortOptions) {
opts.dirsFirst = bool(d)
}

// WithDirsFirst is an option that makes the Sort method order directories
// before leaves.
func WithDirsFirst(value bool) SortOption {
return dirsFirstOption(value)
}

func (d dirsFirstOption) apply(opts *sortOptions) {
opts.dirsFirst = bool(d)
}

func newSortOptions(opts ...SortOption) sortOptions {
var options sortOptions
for _, o := range opts {
Expand Down

0 comments on commit 030be85

Please sign in to comment.