2020-02-05 06:12:33 +01:00
|
|
|
|
|
|
|
fn simple<T>(p T) string {
|
|
|
|
tname := nameof(T)
|
|
|
|
println("Hello generic, I'm an [$tname]")
|
|
|
|
return tname
|
|
|
|
}
|
|
|
|
|
|
|
|
struct FunkyStruct{ }
|
|
|
|
|
|
|
|
fn test_nameof_on_various_types_in_generic() {
|
|
|
|
assert simple(42) == "int"
|
2020-03-19 07:24:49 +01:00
|
|
|
assert simple(3.14) == "f64"
|
2020-02-05 06:12:33 +01:00
|
|
|
assert simple("FuBar") == "string"
|
|
|
|
assert simple(FunkyStruct{}) == "FunkyStruct"
|
|
|
|
assert simple(test_nameof_on_various_types_in_generic) == "fn ()"
|
|
|
|
}
|