Skip to content

Latest commit

 

History

History
39 lines (25 loc) · 705 Bytes

File metadata and controls

39 lines (25 loc) · 705 Bytes

Generic trait

Example

Execute the following command to run ./solutions/examples/generic_trait.rs

cargo run --example generic_trait

Exercises

Exercises are in ./exercises/src/lib.rs

Exercise 1

impl<T> Iterator<T> for TupleIter<T> {
    fn next(&mut self) -> Option<&T> {
        todo!();
    }
}

Implement the Iterator trait for TupleIter<T>.

Return the next element in the tuple until all elements are iterated.

Exercise 2

Implement the Iterator trait for VecIter<T>.

Return the next element in the vector until all elements are iterated.

Test

cargo test