mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-19 06:40:20 +03:00
add impl RocRefcounted for RocResult
This commit is contained in:
parent
0284248320
commit
45cca34c12
@ -214,6 +214,32 @@ impl<T, E> RocResult<T, E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> RocRefcounted for RocResult<T, E>
|
||||
where
|
||||
T: RocRefcounted,
|
||||
E: RocRefcounted,
|
||||
{
|
||||
fn inc(&mut self) {
|
||||
unsafe {
|
||||
match self.tag {
|
||||
RocResultTag::RocOk => (*self.payload.ok).inc(),
|
||||
RocResultTag::RocErr => (*self.payload.err).inc(),
|
||||
}
|
||||
}
|
||||
}
|
||||
fn dec(&mut self) {
|
||||
unsafe {
|
||||
match self.tag {
|
||||
RocResultTag::RocOk => (*self.payload.ok).dec(),
|
||||
RocResultTag::RocErr => (*self.payload.err).dec(),
|
||||
}
|
||||
}
|
||||
}
|
||||
fn is_refcounted() -> bool {
|
||||
T::is_refcounted() || E::is_refcounted()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> From<RocResult<T, E>> for Result<T, E> {
|
||||
fn from(roc_result: RocResult<T, E>) -> Self {
|
||||
use RocResultTag::*;
|
||||
|
Loading…
Reference in New Issue
Block a user