4 ms·
Maybe read a bit on Deref: https://doc.rust-lang.org/std/ops/trait.Deref.html https://doc.rust-lang.org/std/ops/trait.Deref.html Any time you have a &String re
by aldanor 6y ago
Maybe read a bit on Deref: https://doc.rust-lang.org/std/ops/trait.Deref.html https://doc.rust-lang.org/std/ops/trait.Deref.html
Any time you have a &String reference, it triggers coercion to &str.
- Measter 6y agoUnfortunately that is not always the case. This fails to compile, for example (and is fairly irritating): let my_str = "Hello".to_owned(); match &my_str { "Hello" => (), _ => () }