Re:Rust needs to run, and be easy to use, on every platform
by masklinn on Thursday March 08, 2018 @02:51PM
(#16547097)
> You can't deref a String
You can absolutely deref a String. Not necessarily usefully (or to the satisfaction of the compiler) as it yields an unsized `str` (exactly the same as deref'ing an &str) but you can certainly do it.
let a = "foo".to_owned();
let b = &*a;
works perfectly fine.
Incidentally you can also deref' a Vec, that yields a slice (actual sequence, not the commonly seen &[])
You can absolutely deref a String. Not necessarily usefully (or to the satisfaction of the compiler) as it yields an unsized `str` (exactly the same as deref'ing an &str) but you can certainly do it.
works perfectly fine.Incidentally you can also deref' a Vec, that yields a slice (actual sequence, not the commonly seen &[])