rust - How to box a trait that has generic type parameters? -


i able use trait type parameter box<>:

trait ctxval {} type ctxnodes = hashmap<string, box<ctxval>>; 

but when trait has it's own generic type parameters, partialeq, i'm stuck.

type ctxnodes = hashmap<string, box<partialeq>>; 

i error:

main.rs:6:37: 6:46 error: type parameter `rhs` must explicitly specified in        object type because default value `self` references type `self`                              main.rs:6 type ctxnodes = hashmap<string, box<partialeq>>;                                                                                                                                                                               ^~~~~~~~~  

if provide type partialeq, be?

box<partialeq<???>> 

you need specify want object able compared equal to:

fn foo(value: box<partialeq<u8>>) -> bool {     *value == 42 }  fn bar(value: box<partialeq<&str>>) -> bool {     *value == "the answer" } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -