rust - Disambiguate associated type in struct -


i trying run this

use std::collections::btreeset;  pub struct intoiter<t> {     iter: btreeset<t>::intoiter, }  fn main() {} 

playground

this fails with

error[e0223]: ambiguous associated type  --> src/main.rs:4:11   | 4 |     iter: btreeset<t>::intoiter,   |           ^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type   | 

why associated type ambiguous?

"ambiguous" seems bit of misleading wording here. example produces same error message:

struct foo;  pub struct bar {     iter: foo::baz, }  fn main() {} 

i'm not certain, i'd find unlikely there associated type named baz in standard library, less there 2 make ambiguous!

what's more syntax not specific enough. it's plausible there could be multiple traits have baz associated type. because of that, have specify trait want use associated type from:

struct foo;  pub struct bar {     iter: <vec<u8> intoiterator>::intoiter, }  fn main() {} 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -