mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
20 lines
283 B
Plaintext
20 lines
283 B
Plaintext
module std::collections::maybe(<Type>);
|
|
|
|
struct Maybe
|
|
{
|
|
Type value;
|
|
bool has_value;
|
|
}
|
|
|
|
fn Maybe value(Type val)
|
|
{
|
|
return { .value = val, .has_value = true };
|
|
}
|
|
|
|
const Maybe EMPTY = { };
|
|
|
|
macro Type! Maybe.get(self)
|
|
{
|
|
return self.has_value ? self.value : SearchResult.MISSING?;
|
|
}
|