Hi,
I was wondering why
pub fn return_concrete_type_result<T: some_constraints>(&self, for_type: T) {
if dat.type_id() == TypeId::of::<MyType>() {
println!("Equals");
}
and
pub fn return_concrete_type_result<T: some_constraint>(&self, for_type: T) {
let b = TypeId::of::<MyType>();
match for_type.type_id() {
b => { println!("Equals") }
_ => panic!("Unimplemented Type")
}
works
but
pub fn return_concrete_type_result<T: some_constraint>(&self, for_type: T) {
match for_type.type_id() {
TypeId::of::<MyType>() => { println!("Equals") }
_ => panic!("Unimplemented")
}
}
Dont work! Infact does compile.
The compiler complains:
TypeId
Go to TypeId
expected tuple struct or tuple variant, found associated function `TypeId::of::<Unit>`
for more information, visit https://doc.rust-lang.org/book/ch18-00-patterns.htmlrustcClick for full compiler diagnostic
From what I can see both .type_id() and TypeId::of::<>() are returning TypeId structures, unless I cannot just compare structures like that, but then the message doesnt feel accurate, like some of the other messages with help included.
I'm sure is something basic, but I cant seem to understand
Any ideas
Thanks,