Trouble when implmenting fromiterator trait for my struct

Implementing fromiterator trait requires implementing a function takes an IntoIterator as an argument, which creates a lot of trouble for me. When I want to call next() on this IntoIterator parameter, the complier says:

error[E0599]: no method named `next` found for type parameter `T` in the current scope
  --> dna\src\lib.rs:95:32
   |
95 |                     match iter.next() {
   |                                ^^^^ method not found in `T`
   |
   = help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `next`, perhaps you need to restrict type parameter `T` with it:
   |
85 |         fn from_iter<T: Iterator + IntoIterator<Item=Nuc>>(iter: T) -> Self {
   |                      ~~~~~~~~~~~~~

Bur how this be even achieved given the implementor requirements on fromiterator? (I don't want to use for in syntax)

add this before the loop:

let mut iter = iter.into_iter();

this should fix the issue

1 Like

Yes it does thank you!

1 Like

my pleasure!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.