You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Regarding listing-04-09: &String is actually coerced to &str as of rust-lang/rust#21351.
Should this be mentioned at this point in the book?
fn first_word(s:&str) -> &str{
..
fn main(){let my_string = String::from("hello world");// first_word works on slices of `String`slet word = first_word(&my_string[..]);let word = first_word(&my_string);// this is also valid now
..
The text was updated successfully, but these errors were encountered:
Thanks for this! You're right that we could also mention this here, but there's already a lot going on, and understanding this requires knowledge we learn a lot later. I think i'd like to keep it as-is for now. Thank you!
Regarding listing-04-09: &String is actually coerced to &str as of rust-lang/rust#21351.
Should this be mentioned at this point in the book?
The text was updated successfully, but these errors were encountered: