mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 21:29:18 +00:00
The values in the vector are of type &str. But within the tests, the additional & is changing the test strings to type &&str resulting in error E0308 (mismatched types).
error[E0308]: mismatched types
--> exercises/standard_library_types/iterators1.rs:18:5
|
18 | assert_eq!(my_iterable_fav_fruits.next(), Some(&"banana"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `str`, found `&str`
|
= note: expected enum `Option<&str>`
found enum `Option<&&str>`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
(I sure hope that comes out formatted correctly.)
Exercise to Book Chapter mapping
| Exercise | Book Chapter |
|---|---|
| variables | §3.1 |
| functions | §3.3 |
| if | §3.5 |
| move_semantics | §4.1 |
| primitive_types | §4.3 |
| structs | §5.1 |
| enums | §6 |
| modules | §7 |
| collections | §8.1, §8.3 |
| strings | §8.2 |
| error_handling | §9 |
| generics | §10 |
| option | §10.1 |
| traits | §10.2 |
| tests | §11.1 |
| standard_library_types | §13.2 |
| threads | §16.1 |
| macros | §19.6 |
| clippy | n/a |
| conversions | n/a |