It seems that one is not able to cast to a polymorphic type directly e.g.
extern mod std;
fn main () {
let table : std::map::HashMap<int, int> = std::map::HashMap::<int, int>();
(table as std::map::Map<int,int>).insert(123, 1233);
io::println(table.get(123).to_str());
}
does not work, but
extern mod std;
fn main () {
let table : std::map::HashMap<int, int> = std::map::HashMap::<int, int>();
(table as @std::map::Map<int,int>).insert(123, 1233);
io::println(table.get(123).to_str());
}
does.
It might be a documentation bug if one is only allowed to cast to a trait pointer type (as it is shown in the tutorial that one can cast to Drawable trait directly), or it might be an implementation bug regarding traits with type parameters.
It seems that one is not able to cast to a polymorphic type directly e.g.
does not work, but
does.
It might be a documentation bug if one is only allowed to cast to a trait pointer type (as it is shown in the tutorial that one can cast to Drawable trait directly), or it might be an implementation bug regarding traits with type parameters.