Trait implementation docs list methods that can't be called

07e5e8a
Opened by Sebastian Hahn at 2024-11-07 23:23:57

https://doc.rust-lang.org/std/collections/hash_map/struct.Iter.html lists "cloned" as a method for hash_map::Iter, but it doesn't actually exist because the bound on Item cannot be fulfilled. It does not make sense to list that method there, and actually confused me a lot because I thought I should be able to call it.

  1. I believe this has somehow been fixed, I cannot find cloned on that page anymore. Closing!

    Steve Klabnik at 2019-12-25 17:02:01

  2. oops, I was wrong. It's still there.

    Steve Klabnik at 2019-12-25 17:02:41

  3. this would require investigating Self trait bounds, unpacking the associated item bound, and comparing that to the value of the actual associated item.

    this seems like it would almost certainly not be worth it, both in terms of implementation complexity and runtime.

    although i suppose it could be handy if we ever get trivial_bounds

    lolbinarycat at 2024-11-07 23:23:57