3 // Copyright 2022 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
9 func returnOption[T any](n int) Option[T] {
17 type Option[T any] interface {
21 type Some[T any] struct {
25 func (s Some[T]) Value() T {
29 func (s Some[T]) sealedOption() {}
33 func (s None) sealedOption() {}
36 s := returnOption[int](1)
39 s = returnOption[int](0)
42 switch (any)(s).(type) {
44 panic("s is a Some[int]")