monomorphization
This commit is contained in:
parent
32b53ea975
commit
22e2a45401
5 changed files with 1376 additions and 4 deletions
28
tests/generics_comprehensive.sui
Normal file
28
tests/generics_comprehensive.sui
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Generic struct specialization test
|
||||
struct Box<T>
|
||||
value: T
|
||||
end
|
||||
|
||||
# Generic enum specialization test
|
||||
enum Option<T>
|
||||
Some(T),
|
||||
None,
|
||||
end
|
||||
|
||||
# Generic function specialization test
|
||||
fn unwrap<T>(opt: Option<T>) -> T
|
||||
match opt
|
||||
Option::None() => -1,
|
||||
Option::Some(v) => v,
|
||||
end
|
||||
|
||||
# Generic struct with generic enum test
|
||||
fn test_containers() -> int do
|
||||
let box_int = Box { value: 42 };
|
||||
let box_string = Box { value: "Fermented" };
|
||||
let some_int = Option::Some(10);
|
||||
let some_bool = Option::Some(true);
|
||||
let unwrapped = unwrap(some_int);
|
||||
let unwraped_bool = unwrap(some_bool);
|
||||
box_int.value + unwrapped
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue