File: set_extremes.go

package info (click to toggle)
golang-github-apparentlymart-go-versions 1.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 292 kB
  • sloc: makefile: 2
file content (49 lines) | stat: -rw-r--r-- 792 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package versions

// All is an infinite set containing all possible versions.
var All Set

// None is a finite set containing no versions.
var None Set

type setExtreme bool

func (s setExtreme) Has(v Version) bool {
	return bool(s)
}

func (s setExtreme) AllRequested() Set {
	// The extreme sets request nothing.
	return None
}

func (s setExtreme) GoString() string {
	switch bool(s) {
	case true:
		return "versions.All"
	case false:
		return "versions.None"
	default:
		panic("strange new boolean value")
	}
}

var _ setFinite = setExtreme(false)

func (s setExtreme) isFinite() bool {
	// Only None is finite
	return !bool(s)
}

func (s setExtreme) listVersions() List {
	return nil
}

func init() {
	All = Set{
		setI: setExtreme(true),
	}
	None = Set{
		setI: setExtreme(false),
	}
}