Finish transition.
This commit is contained in:
parent
a6ec3f2272
commit
3f001239d6
1 changed files with 36 additions and 6 deletions
|
@ -59,7 +59,7 @@ impl<T> FromRc<T> for Rc<T> where T: Sized + Clone {
|
||||||
fn from_arc(val: Arc<T>) -> Self {
|
fn from_arc(val: Arc<T>) -> Self {
|
||||||
match ::std::sync::Arc::<T>::try_unwrap(val) {
|
match ::std::sync::Arc::<T>::try_unwrap(val) {
|
||||||
Ok(v) => Self::new(v),
|
Ok(v) => Self::new(v),
|
||||||
Err(r) => Self::new((*r.as_ref()).clone()),
|
Err(r) => Self::new(r.cloned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ impl<T> FromRc<T> for Arc<T> where T: Sized + Clone {
|
||||||
fn from_rc(val: Rc<T>) -> Self {
|
fn from_rc(val: Rc<T>) -> Self {
|
||||||
match ::std::rc::Rc::<T>::try_unwrap(val) {
|
match ::std::rc::Rc::<T>::try_unwrap(val) {
|
||||||
Ok(v) => Self::new(v),
|
Ok(v) => Self::new(v),
|
||||||
Err(r) => Self::new((*r.as_ref()).clone()),
|
Err(r) => Self::new(r.cloned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,22 @@ impl<T> FromRc<T> for Arc<T> where T: Sized + Clone {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> FromRc<T> for Box<T> where T: Sized + Clone {
|
||||||
|
fn from_rc(val: Rc<T>) -> Self {
|
||||||
|
match ::std::rc::Rc::<T>::try_unwrap(val) {
|
||||||
|
Ok(v) => Self::new(v),
|
||||||
|
Err(r) => Self::new(r.cloned()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn from_arc(val: Arc<T>) -> Self {
|
||||||
|
match ::std::sync::Arc::<T>::try_unwrap(val) {
|
||||||
|
Ok(v) => Self::new(v),
|
||||||
|
Err(r) => Self::new(r.cloned()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We do this a lot for errors.
|
// We do this a lot for errors.
|
||||||
pub trait Cloned<T> {
|
pub trait Cloned<T> {
|
||||||
fn cloned(&self) -> T;
|
fn cloned(&self) -> T;
|
||||||
|
@ -94,9 +110,17 @@ impl<T: Clone> Cloned<T> for Arc<T> where T: Sized + Clone {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
impl<T: Clone> Cloned<T> for Box<T> where T: Sized + Clone {
|
||||||
// Use Rc for values.
|
fn cloned(&self) -> T {
|
||||||
//
|
self.as_ref().clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// This type alias exists to allow us to use different boxing mechanisms for values.
|
||||||
|
/// This type must implement `FromRc` and `Cloned`, and a `From` implementation must exist for
|
||||||
|
/// `TypedValue`.
|
||||||
|
///
|
||||||
pub type ValueRc<T> = Rc<T>;
|
pub type ValueRc<T> = Rc<T>;
|
||||||
|
|
||||||
/// Represents one entid in the entid space.
|
/// Represents one entid in the entid space.
|
||||||
|
@ -284,7 +308,7 @@ impl Binding {
|
||||||
///
|
///
|
||||||
/// We entirely support the former, and partially support the latter -- you can alias
|
/// We entirely support the former, and partially support the latter -- you can alias
|
||||||
/// using a different keyword only.
|
/// using a different keyword only.
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct StructuredMap(IndexMap<ValueRc<NamespacedKeyword>, Binding>);
|
pub struct StructuredMap(IndexMap<ValueRc<NamespacedKeyword>, Binding>);
|
||||||
|
|
||||||
impl Binding {
|
impl Binding {
|
||||||
|
@ -424,6 +448,12 @@ impl From<Rc<String>> for TypedValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Box<String>> for TypedValue {
|
||||||
|
fn from(value: Box<String>) -> TypedValue {
|
||||||
|
TypedValue::String(ValueRc::new(*value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<String> for TypedValue {
|
impl From<String> for TypedValue {
|
||||||
fn from(value: String) -> TypedValue {
|
fn from(value: String) -> TypedValue {
|
||||||
TypedValue::String(ValueRc::new(value))
|
TypedValue::String(ValueRc::new(value))
|
||||||
|
|
Loading…
Reference in a new issue