first commit
This commit is contained in:
commit
4ff159dd4a
20 changed files with 6529 additions and 0 deletions
34
tests/enums.sui
Normal file
34
tests/enums.sui
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# Enum test
|
||||
enum Color
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
end
|
||||
|
||||
enum Result<T, E>
|
||||
Ok(T),
|
||||
Err(E),
|
||||
end
|
||||
|
||||
struct Person
|
||||
name: string,
|
||||
age: int,
|
||||
end
|
||||
|
||||
fn main() -> int do
|
||||
let color = Color::Red();
|
||||
let res = Result::Ok(42);
|
||||
match res
|
||||
Result::Ok(value) => value,
|
||||
Result::Err(_) => 0,
|
||||
end
|
||||
let person = Person { name: "Bob", age: 25 };
|
||||
match color
|
||||
Color::Red() => 1,
|
||||
Color::Green() => 2,
|
||||
Color::Blue() => 3,
|
||||
end
|
||||
match person
|
||||
Person { name: _, age: age } => age,
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue