mirror of
https://github.com/mainmatter/100-exercises-to-learn-rust
synced 2024-12-25 21:58:26 +01:00
Give a more structure hint for iteration exercises (#235)
This commit is contained in:
parent
60947aaacd
commit
d5e1c00108
2 changed files with 7 additions and 0 deletions
|
@ -5,6 +5,9 @@ use ticket_fields::{TicketDescription, TicketTitle};
|
|||
// it contains using a `for` loop.
|
||||
//
|
||||
// Hint: you shouldn't have to implement the `Iterator` trait in this case.
|
||||
// You want to *delegate* the iteration to the `Vec<Ticket>` field in `TicketStore`.
|
||||
// Look at the standard library documentation for `Vec` to find the right type
|
||||
// to return from `into_iter`.
|
||||
#[derive(Clone)]
|
||||
pub struct TicketStore {
|
||||
tickets: Vec<Ticket>,
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
use ticket_fields::{TicketDescription, TicketTitle};
|
||||
|
||||
// TODO: Provide an `iter` method that returns an iterator over `&Ticket` items.
|
||||
//
|
||||
// Hint: just like in the previous exercise, you want to delegate the iteration to
|
||||
// the `Vec<Ticket>` field in `TicketStore`. Look at the standard library documentation
|
||||
// for `Vec` to find the right type to return from `iter`.
|
||||
#[derive(Clone)]
|
||||
pub struct TicketStore {
|
||||
tickets: Vec<Ticket>,
|
||||
|
|
Loading…
Reference in a new issue