Open NobodyXu opened 5 months ago
Just noting that if this gets added, there would need to be a fallback to Rc<str>
on systems without #[cfg(target_has_atomic = "ptr")]
(docs). Or maybe better, support Rc<str>
on all platforms and just conditionally also support Arc<str>
on platforms that allow it.
Thx, I forgot existence of Rc<str>
and problems of atomics not present for a while.
While I agree it'd be a good idea, supporting Rc<str>
means CompactString
would no longer be Send
.
We can conditionally support Arc<str>
on platforms that support it, and for other platforms, IMO it's Arc<T>
's job to fallback to Rc<T>
implementation, because we don't know if it's safe to fallback to it (only when the program is single-threaded).
Ah, that's true, and a fallback to Rc<str>
would also break Send
. In that case, it might be best to just support Arc<str>
when it exists on the arch and just not allow that (with no fallback) otherwise.
I think it makes sense to support
Arc<str>
inCompactString
as a new repr, it would then enable O(1) cloning, which is very handy for parser/configuration.