4 ms·
A `&str` is a borrow of the string slice data, and has borrowing semantics. An `std::sync::Arc<str>` on the other hand isn't borrowed but has shared ownership a
by phaylon 5y ago
A `&str` is a borrow of the string slice data, and has borrowing semantics. An `std::sync::Arc<str>` on the other hand isn't borrowed but has shared ownership and is atomically reference counted.
Does that answer the question? Could you expand on what you mean by sharing `&str`?
- rmdashrfstar 5y agoI suppose my question is what motivates the use of atomically referencing counting string slice rather than borrowing?
- phaylon 5y agoYou can store it independently without it being borrowed. So your structs don't need lifetimes. I consider it a midpoint between `String` and `&str`. Most of the convenience of `String` (barring mutation) but less costly.