Move Cloned to core.

This commit is contained in:
Richard Newman 2018-04-25 12:51:36 -07:00
parent 1918388ddf
commit 5440efa4bf
4 changed files with 20 additions and 17 deletions

View file

@ -55,6 +55,7 @@ mod value_type_set;
mod sql_types;
pub use types::{
Cloned,
Entid,
FromRc,
KnownEntid,

View file

@ -72,6 +72,23 @@ impl<T> FromRc<T> for Arc<T> where T: Sized + Clone {
}
}
// We do this a lot for errors.
pub trait Cloned<T> {
fn cloned(&self) -> T;
}
impl<T: Clone> Cloned<T> for Rc<T> where T: Sized + Clone {
fn cloned(&self) -> T {
(*self.as_ref()).clone()
}
}
impl<T: Clone> Cloned<T> for Arc<T> where T: Sized + Clone {
fn cloned(&self) -> T {
(*self.as_ref()).clone()
}
}
//
// Use Rc for values.
//

View file

@ -25,12 +25,9 @@ use std::fmt::{
Formatter,
};
use std::ops::{
Deref,
};
use mentat_core::{
Attribute,
Cloned,
Entid,
HasSchema,
KnownEntid,
@ -100,17 +97,6 @@ pub use self::inputs::QueryInputs;
use Known;
// We do this a lot for errors.
trait Cloned<T> {
fn cloned(&self) -> T;
}
impl<T: Clone> Cloned<T> for ::mentat_core::ValueRc<T> {
fn cloned(&self) -> T {
self.deref().clone()
}
}
trait Contains<K, T> {
fn when_contains<F: FnOnce() -> T>(&self, k: &K, f: F) -> Option<T>;
}

View file

@ -9,6 +9,7 @@
// specific language governing permissions and limitations under the License.
use mentat_core::{
Cloned,
Entid,
HasSchema,
TypedValue,
@ -24,8 +25,6 @@ use mentat_query::{
Variable,
};
use super::Cloned;
use clauses::{
ConjoiningClauses,
};