-
-
Notifications
You must be signed in to change notification settings - Fork 9
Optional
Optional represents the type of a value that might exist.
| Type | Size | Memory Management Model | File |
|---|---|---|---|
Optional |
? bytes | Scoped | 2.7/Optional.adept |
struct <$T> Optional (value $T, has bool)
where
$T is any valid type
| Name | Type | Description |
|---|---|---|
has |
bool |
Whether a value exists |
value |
$T |
Wrapped value, only exists if has is true |
verbatim func __defer__(this *<$T> Optional)
optional.value is freed at the end of the scope if optional.has is true.
-
func none() <$T> OptionalReturns an empty optional. Should be used with
~>operator likenone() ~> <int> Optional. -
func some(contained POD $T) <$T> OptionalReturns an optional with a contained value. The contained value is copied byte for byte, so some values may need modifications before being given to this function.
-
func set(this *<$T> Optional, value POD $T) voidSets an optional to a value. The value is copied byte for byte, so some values may need modifications before being given to this function.
-
func get(this *<$T> Optional) $TGets the contained value of an optional.
-
func getPointer(this *<$T> Optional) *$TGets a pointer to the contained value of an optional.
-
func rid(this *<$T> Optional) voidSets an optional to not contain anything.
#default optional_warn_no_value true