diff options
author | 6543 <6543@obermui.de> | 2024-03-02 16:42:31 +0100 |
---|---|---|
committer | Earl Warren <contact@earl-warren.org> | 2024-03-06 05:10:46 +0100 |
commit | e2371743d5e50d1fe8efeb55fa7d9f9f96668430 (patch) | |
tree | cc6003558f67e305bfe7ee172e3c0b0b4a9907be /modules/util | |
parent | Rename Action.GetDisplayName to GetActDisplayName (#29540) (diff) | |
download | forgejo-e2371743d5e50d1fe8efeb55fa7d9f9f96668430.tar.xz forgejo-e2371743d5e50d1fe8efeb55fa7d9f9f96668430.zip |
remove util.OptionalBool and related functions (#29513)
and migrate affected code
_last refactoring bits to replace **util.OptionalBool** with
**optional.Option[bool]**_
(cherry picked from commit a3f05d0d98408bb47333b19f505b21afcefa9e7c)
Conflicts:
services/repository/branch.go
trivial context conflict
Diffstat (limited to 'modules/util')
-rw-r--r-- | modules/util/util.go | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/modules/util/util.go b/modules/util/util.go index 615f654e47..5c75158196 100644 --- a/modules/util/util.go +++ b/modules/util/util.go @@ -17,57 +17,6 @@ import ( "golang.org/x/text/language" ) -// OptionalBool a boolean that can be "null" -type OptionalBool byte - -const ( - // OptionalBoolNone a "null" boolean value - OptionalBoolNone OptionalBool = iota - // OptionalBoolTrue a "true" boolean value - OptionalBoolTrue - // OptionalBoolFalse a "false" boolean value - OptionalBoolFalse -) - -// IsTrue return true if equal to OptionalBoolTrue -func (o OptionalBool) IsTrue() bool { - return o == OptionalBoolTrue -} - -// IsFalse return true if equal to OptionalBoolFalse -func (o OptionalBool) IsFalse() bool { - return o == OptionalBoolFalse -} - -// IsNone return true if equal to OptionalBoolNone -func (o OptionalBool) IsNone() bool { - return o == OptionalBoolNone -} - -// ToGeneric converts OptionalBool to optional.Option[bool] -func (o OptionalBool) ToGeneric() optional.Option[bool] { - if o.IsNone() { - return optional.None[bool]() - } - return optional.Some[bool](o.IsTrue()) -} - -// OptionalBoolFromGeneric converts optional.Option[bool] to OptionalBool -func OptionalBoolFromGeneric(o optional.Option[bool]) OptionalBool { - if o.Has() { - return OptionalBoolOf(o.Value()) - } - return OptionalBoolNone -} - -// OptionalBoolOf get the corresponding OptionalBool of a bool -func OptionalBoolOf(b bool) OptionalBool { - if b { - return OptionalBoolTrue - } - return OptionalBoolFalse -} - // OptionalBoolParse get the corresponding optional.Option[bool] of a string using strconv.ParseBool func OptionalBoolParse(s string) optional.Option[bool] { v, e := strconv.ParseBool(s) |