Skip to content

Commit b8d70f2

Browse files
committed
Correct isSome representation in option
Signed-off-by: Till Schneidereit <till@tillschneidereit.net>
1 parent 4604c9a commit b8d70f2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cm/option.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func Some[T any](v T) Option[T] {
2929
// followed by storage for the associated type T.
3030
type option[T any] struct {
3131
_ HostLayout
32-
isSome uint8
32+
isSome uint32
3333
some T
3434
}
3535

@@ -47,6 +47,10 @@ func (o *option[T]) Some() *T {
4747
return nil
4848
}
4949

50+
func (o option[T]) IsSome() bool {
51+
return o.isSome == 1
52+
}
53+
5054
// Value returns T if o represents the some case,
5155
// or the zero value of T if o represents the none case.
5256
// This does not have a pointer receiver, so it can be chained.

0 commit comments

Comments
 (0)