3 ms·
I see! That makes sense now. Unsized types are one of the Rust concepts that I haven't gotten a good handle on yet, probably mainly because they don't come up v
by brundolf 6y ago
I see! That makes sense now. Unsized types are one of the Rust concepts that I haven't gotten a good handle on yet, probably mainly because they don't come up very often in practice. The only other one I know of is str, and I'm not even sure how I'd go about using a plain str.
- steveklabnik 6y agoTotally. It works the same way: it's gotta be behind a pointer. Arc<str> would be a signature for a threadsafe interned string, for example. use std::sync::Arc; fn foobar(s: &str) -> Arc<str> { Arc::from(s.to_string()) } You almost always can only create these sorts of values by casting.