From 52dc112410d2e047663e6ceb52d61aff860b18ca Mon Sep 17 00:00:00 2001 From: pca006132 Date: Tue, 3 Aug 2021 12:35:58 +0800 Subject: [PATCH] unification table: modified conversion impl from UnificationTable> <==> UnificationTable to UnificationTable> <==> UnificationTable --- nac3core/src/typecheck/unification_table.rs | 35 +++++---------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/nac3core/src/typecheck/unification_table.rs b/nac3core/src/typecheck/unification_table.rs index 60ec8086..588cf4bb 100644 --- a/nac3core/src/typecheck/unification_table.rs +++ b/nac3core/src/typecheck/unification_table.rs @@ -1,4 +1,3 @@ -use std::cell::RefCell; use std::rc::Rc; #[derive(Copy, Clone, PartialEq, Eq, Debug)] @@ -12,11 +11,7 @@ pub struct UnificationTable { impl UnificationTable { pub fn new() -> UnificationTable { - UnificationTable { - parents: Vec::new(), - ranks: Vec::new(), - values: Vec::new(), - } + UnificationTable { parents: Vec::new(), ranks: Vec::new(), values: Vec::new() } } pub fn new_key(&mut self, v: V) -> UnificationKey { @@ -72,33 +67,17 @@ impl UnificationTable { } } -impl UnificationTable>> +impl UnificationTable> where V: Clone, { pub fn into_send(self) -> UnificationTable { - let values = self - .values - .iter() - .map(|v| v.as_ref().borrow().clone()) - .collect(); - UnificationTable { - parents: self.parents, - ranks: self.ranks, - values, - } + let values = self.values.iter().map(|v| v.as_ref().clone()).collect(); + UnificationTable { parents: self.parents, ranks: self.ranks, values } } - pub fn from_send(table: UnificationTable) -> UnificationTable>> { - let values = table - .values - .into_iter() - .map(|v| Rc::new(RefCell::new(v))) - .collect(); - UnificationTable { - parents: table.parents, - ranks: table.ranks, - values, - } + pub fn from_send(table: UnificationTable) -> UnificationTable> { + let values = table.values.into_iter().map(Rc::new).collect(); + UnificationTable { parents: table.parents, ranks: table.ranks, values } } }