Re:Learning Rust via Advent of Code
by steveklabnik on Monday February 04, 2019 @05:30PM
(#19081298)
&str is not the same as &[char]. &str has the same memory representation as &[u8]. char is four bytes, not one.
Thanks Steve.
Re:Learning Rust via Advent of Code
by steveklabnik on Tuesday February 05, 2019 @03:14AM
(#19083707)
No problem! It's an easy mistake to make.
The operator for this is for eg l[1..10]. It can also happen automatically.
&str is the same type as &[char] - just a renaming.
Still learning Rust myself, apologies if this leads you astray. Just do some reading on slices.
https://doc.rust-lang.org/book/ch04-03-slices.html#string-sl...
https://doc.rust-lang.org/std/slice/