zlacker

[parent] [thread] 2 comments
1. adastr+(OP)[view] [source] 2025-08-22 16:35:08
. (early morning brain fart -- I need my coffee)
replies(1): >>tialar+H1
2. tialar+H1[view] [source] 2025-08-22 16:44:13
>>adastr+(OP)
So it's true that technically the primitive type is str, and indeed it's even possible to make a &mut str though it's quite rare that you'd want to mutably borrow the string slice.

However no &str is not "an alias for &&String" and I can't quite imagine how you'd think that. String doesn't exist in Rust's core, it's from alloc and thus wouldn't be available if you don't have an allocator.

replies(1): >>zozbot+I3
◧◩
3. zozbot+I3[view] [source] [discussion] 2025-08-22 16:53:39
>>tialar+H1
str is not really a "primitive type", it only exists abstractly as an argument to type constructors - treating the & operator as a "type constructor" for that purpose, but including Box<>, Rc<>, Arc<> etc. So you can have Box<str> or Arc<str> in addition to &str or perhaps &mut str, but not really 'str' in isolation.
[go to top]