mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
add RocRefcounted to SendSafe types
This commit is contained in:
parent
f8b0be725c
commit
0e162a767d
2 changed files with 31 additions and 0 deletions
|
@ -860,6 +860,23 @@ where
|
||||||
|
|
||||||
unsafe impl<T> Send for SendSafeRocList<T> where T: Send + RocRefcounted {}
|
unsafe impl<T> Send for SendSafeRocList<T> where T: Send + RocRefcounted {}
|
||||||
|
|
||||||
|
impl<T> RocRefcounted for SendSafeRocList<T>
|
||||||
|
where
|
||||||
|
T: RocRefcounted,
|
||||||
|
{
|
||||||
|
fn inc(&mut self) {
|
||||||
|
self.0.inc()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dec(&mut self) {
|
||||||
|
self.0.dec()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_refcounted() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Clone for SendSafeRocList<T>
|
impl<T> Clone for SendSafeRocList<T>
|
||||||
where
|
where
|
||||||
T: Clone + RocRefcounted,
|
T: Clone + RocRefcounted,
|
||||||
|
|
|
@ -764,6 +764,20 @@ pub struct SendSafeRocStr(RocStr);
|
||||||
|
|
||||||
unsafe impl Send for SendSafeRocStr {}
|
unsafe impl Send for SendSafeRocStr {}
|
||||||
|
|
||||||
|
impl RocRefcounted for SendSafeRocStr {
|
||||||
|
fn inc(&mut self) {
|
||||||
|
self.0.inc()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dec(&mut self) {
|
||||||
|
self.0.dec()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_refcounted() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Clone for SendSafeRocStr {
|
impl Clone for SendSafeRocStr {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
if self.0.is_readonly() {
|
if self.0.is_readonly() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue