mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
add clone to SendSafe* types
This commit is contained in:
parent
24cd78fe7e
commit
6ebfcc8fa1
2 changed files with 25 additions and 0 deletions
|
@ -657,6 +657,17 @@ pub struct SendSafeRocStr(RocStr);
|
|||
|
||||
unsafe impl Send for SendSafeRocStr {}
|
||||
|
||||
impl Clone for SendSafeRocStr {
|
||||
fn clone(&self) -> Self {
|
||||
if self.0.is_readonly() {
|
||||
SendSafeRocStr(self.0.clone())
|
||||
} else {
|
||||
// To keep self send safe, this must copy.
|
||||
SendSafeRocStr(RocStr::from(self.0.as_str()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RocStr> for SendSafeRocStr {
|
||||
fn from(s: RocStr) -> Self {
|
||||
if s.is_unique() || s.is_readonly() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue