Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 1 of 1 for sealedOption (0.11 sec)

  1. test/typeparam/issue52026.go

    	if n == 1 {
    		return Some[T]{}
    	} else {
    		return None{}
    	}
    }
    
    type Option[T any] interface {
    	sealedOption()
    }
    
    type Some[T any] struct {
    	val T
    }
    
    func (s Some[T]) Value() T {
    	return s.val
    }
    
    func (s Some[T]) sealedOption() {}
    
    type None struct{}
    
    func (s None) sealedOption() {}
    
    func main() {
    	s := returnOption[int](1)
    	_ = s.(Some[int])
    
    	s = returnOption[int](0)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue May 03 21:36:22 UTC 2022
    - 735 bytes
    - Viewed (0)
Back to top