mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
27 lines
394 B
V
27 lines
394 B
V
module main
|
|
|
|
pub struct Reptile {}
|
|
|
|
pub struct Insect {}
|
|
|
|
fn test_generics_with_nested_generic_fn_infer_call() {
|
|
mut r := Reptile{}
|
|
mut i := Insect{}
|
|
|
|
ret1 := node_search(mut r)
|
|
println(ret1)
|
|
assert ret1 == Reptile{}
|
|
|
|
ret2 := node_search(mut i)
|
|
println(ret2)
|
|
assert ret2 == Insect{}
|
|
}
|
|
|
|
pub fn node_search[T](mut t T) T {
|
|
return hydrate(mut t)
|
|
}
|
|
|
|
fn hydrate[T](mut t T) T {
|
|
return t
|
|
}
|