-
-
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.8/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> Optional
Returns an empty optional. Should be used with
~>
operator likenone() ~> <int> Optional
. -
func some(contained POD $T) <$T> Optional
Returns 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) void
Sets 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) $T
Gets the contained value of an optional.
-
func getPointer(this *<$T> Optional) *$T
Gets a pointer to the contained value of an optional.
-
func rid(this *<$T> Optional) void
Sets an optional to not contain anything.
#default optional_warn_no_value true