2 ms·
> 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` (
by masklinn 9y ago
> 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 &[])