1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2026-05-16 09:38:12 +02:00

Merge pull request #2388 from senekor/senekor/vnopstqrrszn

Use slice instead of array in iterator1
This commit is contained in:
Mo Bitar
2026-05-09 10:41:13 +02:00
committed by GitHub
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -10,9 +10,9 @@ fn main() {
mod tests {
#[test]
fn iterators() {
let my_fav_fruits = ["banana", "custard apple", "avocado", "peach", "raspberry"];
let my_fav_fruits = &["banana", "custard apple", "avocado", "peach", "raspberry"];
// TODO: Create an iterator over the array.
// TODO: Create an iterator over the slice.
let mut fav_fruits_iterator = todo!();
assert_eq!(fav_fruits_iterator.next(), Some(&"banana"));
+2 -2
View File
@@ -10,9 +10,9 @@ fn main() {
mod tests {
#[test]
fn iterators() {
let my_fav_fruits = ["banana", "custard apple", "avocado", "peach", "raspberry"];
let my_fav_fruits = &["banana", "custard apple", "avocado", "peach", "raspberry"];
// Create an iterator over the array.
// Create an iterator over the slice.
let mut fav_fruits_iterator = my_fav_fruits.iter();
assert_eq!(fav_fruits_iterator.next(), Some(&"banana"));