pub struct Moo<T> { /* private fields */ }Expand description
A clone-on-write, reference counted pointer to an AST type.
Cloning values of this type will not clone the underlying value until it is modified, e.g.,
with Moo::make_mut.
Unlike Rc and Arc, trait implementations on this type do not need to preserve shared
ownership - that is, two pointers that used to point to the same value may not do so after
calling a trait method on them. In particular, calling Uniplate methods may cause a
clone-on-write to occur.
Note: like BoxandRc, methods on Mooare all associated functions, which means you have to call them as, e.g.Moo::make_mut(&value)instead ofvalue.make_mut(). This is so that there are no conflicts with the inner type T`, which this type dereferences to.
Implementations§
Source§impl Moo<Domain>
impl Moo<Domain>
pub fn resolve(&self) -> Result<Moo<GroundDomain>, DomainOpError>
Sourcepub fn union(&self, other: &DomainPtr) -> Result<DomainPtr, DomainOpError>
pub fn union(&self, other: &DomainPtr) -> Result<DomainPtr, DomainOpError>
Convenience method to take Domain::union of the Domains behind two DomainPtrs and wrap the result in a new DomainPtr.
Sourcepub fn intersect(&self, other: &DomainPtr) -> Result<DomainPtr, DomainOpError>
pub fn intersect(&self, other: &DomainPtr) -> Result<DomainPtr, DomainOpError>
Convenience method to take Domain::intersect of the Domains behind two DomainPtrs and wrap the result in a new DomainPtr.
Source§impl<T: Clone> Moo<T>
impl<T: Clone> Moo<T>
Sourcepub fn make_mut(this: &mut Moo<T>) -> &mut T
pub fn make_mut(this: &mut Moo<T>) -> &mut T
Makes a mutable reference into the given Moo.
If there are other Moo pointers to the same allocation, then make_mut will clone the
inner value to a new allocation to ensure unique ownership. This is also referred to as
clone-on-write.
Sourcepub fn unwrap_or_clone(this: Moo<T>) -> T
pub fn unwrap_or_clone(this: Moo<T>) -> T
If we have the only reference to T then unwrap it. Otherwise, clone T and return the clone.
Assuming moo_t is of type Moo<T>, this function is functionally equivalent to
(*moo_t).clone(), but will avoid cloning the inner value where possible.
Trait Implementations§
Source§impl Biplate<Moo<Domain>> for Domain
impl Biplate<Moo<Domain>> for Domain
Source§fn biplate(&self) -> (Tree<DomainPtr>, Box<dyn Fn(Tree<DomainPtr>) -> Domain>)
fn biplate(&self) -> (Tree<DomainPtr>, Box<dyn Fn(Tree<DomainPtr>) -> Domain>)
§fn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
§fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
Uniplate::descend] Read more§fn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
§fn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
§fn children_bi_count(&self) -> usize
fn children_bi_count(&self) -> usize
children_bi. Read more§fn try_replace_child_at_bi(&mut self, index: usize, child: To) -> bool
fn try_replace_child_at_bi(&mut self, index: usize, child: To) -> bool
§fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
§fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
§fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
Source§impl Biplate<Moo<Domain>> for UnresolvedDomain
impl Biplate<Moo<Domain>> for UnresolvedDomain
Source§fn biplate(
&self,
) -> (Tree<DomainPtr>, Box<dyn Fn(Tree<DomainPtr>) -> UnresolvedDomain>)
fn biplate( &self, ) -> (Tree<DomainPtr>, Box<dyn Fn(Tree<DomainPtr>) -> UnresolvedDomain>)
§fn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
§fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
Uniplate::descend] Read more§fn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
§fn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
§fn children_bi_count(&self) -> usize
fn children_bi_count(&self) -> usize
children_bi. Read more§fn try_replace_child_at_bi(&mut self, index: usize, child: To) -> bool
fn try_replace_child_at_bi(&mut self, index: usize, child: To) -> bool
§fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
§fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
§fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
Source§impl Biplate<Moo<Domain>> for Expression
impl Biplate<Moo<Domain>> for Expression
Source§fn biplate(
&self,
) -> (Tree<DomainPtr>, Box<dyn Fn(Tree<DomainPtr>) -> Expression>)
fn biplate( &self, ) -> (Tree<DomainPtr>, Box<dyn Fn(Tree<DomainPtr>) -> Expression>)
§fn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
§fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
Uniplate::descend] Read more§fn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
§fn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
§fn children_bi_count(&self) -> usize
fn children_bi_count(&self) -> usize
children_bi. Read more§fn try_replace_child_at_bi(&mut self, index: usize, child: To) -> bool
fn try_replace_child_at_bi(&mut self, index: usize, child: To) -> bool
§fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
§fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
§fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
Source§impl<To, U> Biplate<To> for Moo<U>where
To: Uniplate,
U: Uniplate + Biplate<To>,
impl<To, U> Biplate<To> for Moo<U>where
To: Uniplate,
U: Uniplate + Biplate<To>,
Source§fn children_bi_count(&self) -> usize
fn children_bi_count(&self) -> usize
Counts children through the pointer, without cloning the pointee.
The default implementation materialises children_bi, which goes via [Biplate::biplate]
and therefore clones the whole inner value. Payload syncs call this once per tree level, so
the default turns a single rewrite under a wide node (e.g. or over a large matrix) into
O(n) work, and a full rewrite pass into O(n^2).
Source§fn try_replace_child_at_bi(&mut self, index: usize, child: To) -> bool
fn try_replace_child_at_bi(&mut self, index: usize, child: To) -> bool
Replaces a child through the pointer, cloning the pointee only when it is shared.
Mirrors [Biplate::children_bi_count] above: the default implementation clones the inner
value twice (once to list children, once to rebuild) and structurally compares the old and
new trees.
Source§fn biplate(&self) -> (Tree<To>, Box<dyn Fn(Tree<To>) -> Self>)
fn biplate(&self) -> (Tree<To>, Box<dyn Fn(Tree<To>) -> Self>)
§fn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
§fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
Uniplate::descend] Read more§fn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
§fn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
§fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
§fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
§fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for Moo<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Moo<T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'de, T, As> DeserializeAs<'de, Moo<T>> for Moo<As>where
As: DeserializeAs<'de, T>,
impl<'de, T, As> DeserializeAs<'de, Moo<T>> for Moo<As>where
As: DeserializeAs<'de, T>,
Source§fn deserialize_as<D>(deserializer: D) -> Result<Moo<T>, D::Error>where
D: Deserializer<'de>,
fn deserialize_as<D>(deserializer: D) -> Result<Moo<T>, D::Error>where
D: Deserializer<'de>,
impl<T: Eq> Eq for Moo<T>
Source§impl From<&Moo<GroundDomain>> for DomainPtr
impl From<&Moo<GroundDomain>> for DomainPtr
Source§fn from(value: &Moo<GroundDomain>) -> Self
fn from(value: &Moo<GroundDomain>) -> Self
Source§impl From<&Moo<UnresolvedDomain>> for DomainPtr
impl From<&Moo<UnresolvedDomain>> for DomainPtr
Source§fn from(value: &Moo<UnresolvedDomain>) -> Self
fn from(value: &Moo<UnresolvedDomain>) -> Self
Source§impl From<Moo<Expression>> for Expression
impl From<Moo<Expression>> for Expression
Source§fn from(val: Moo<Expression>) -> Self
fn from(val: Moo<Expression>) -> Self
Source§impl From<Moo<GroundDomain>> for DomainPtr
impl From<Moo<GroundDomain>> for DomainPtr
Source§fn from(value: Moo<GroundDomain>) -> Self
fn from(value: Moo<GroundDomain>) -> Self
Source§impl From<Moo<UnresolvedDomain>> for DomainPtr
impl From<Moo<UnresolvedDomain>> for DomainPtr
Source§fn from(value: Moo<UnresolvedDomain>) -> Self
fn from(value: Moo<UnresolvedDomain>) -> Self
Source§impl<A, B> FuncMap<A, B> for Moo<A>where
A: Clone,
impl<A, B> FuncMap<A, B> for Moo<A>where
A: Clone,
Source§fn func_map<F>(self, f: F) -> Self::Outputwhere
F: FnMut(A) -> B,
fn func_map<F>(self, f: F) -> Self::Outputwhere
F: FnMut(A) -> B,
f to self in a functorial way§fn func_map_over<Q, F>(self, f: F) -> Self::Outputwhere
F: FnMut(A) -> B,
Q: FuncMarker<P>,
fn func_map_over<Q, F>(self, f: F) -> Self::Outputwhere
F: FnMut(A) -> B,
Q: FuncMarker<P>,
f to self in a functorial way, allowing explicit
specification of the marker type P Read moreSource§impl<T: Quine> Quine for Moo<T>
impl<T: Quine> Quine for Moo<T>
fn ctor_tokens(&self) -> TokenStream
Source§impl<T, As> SerializeAs<Moo<T>> for Moo<As>where
As: SerializeAs<T>,
impl<T, As> SerializeAs<Moo<T>> for Moo<As>where
As: SerializeAs<T>,
Source§fn serialize_as<S>(source: &Moo<T>, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize_as<S>(source: &Moo<T>, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,
impl<T: PartialEq> StructuralPartialEq for Moo<T>
Source§impl<A, B> TryFuncMap<A, B> for Moo<A>where
A: Clone,
impl<A, B> TryFuncMap<A, B> for Moo<A>where
A: Clone,
Source§fn try_func_map<E, F>(self, f: F) -> Result<Self::Output, E>
fn try_func_map<E, F>(self, f: F) -> Result<Self::Output, E>
Source§impl<T> Uniplate for Moo<T>where
T: Uniplate,
impl<T> Uniplate for Moo<T>where
T: Uniplate,
Source§fn uniplate(&self) -> (Tree<Self>, Box<dyn Fn(Tree<Self>) -> Self>)
fn uniplate(&self) -> (Tree<Self>, Box<dyn Fn(Tree<Self>) -> Self>)
Uniplate. Read more§fn descend(&self, op: &impl Fn(Self) -> Self) -> Self
fn descend(&self, op: &impl Fn(Self) -> Self) -> Self
§fn universe(&self) -> VecDeque<Self>
fn universe(&self) -> VecDeque<Self>
§fn with_children(&self, children: VecDeque<Self>) -> Self
fn with_children(&self, children: VecDeque<Self>) -> Self
§fn try_replace_child_at(&mut self, index: usize, child: Self) -> bool
fn try_replace_child_at(&mut self, index: usize, child: Self) -> bool
§fn transform(&self, f: &impl Fn(Self) -> Self) -> Self
fn transform(&self, f: &impl Fn(Self) -> Self) -> Self
§fn rewrite(&self, f: &impl Fn(Self) -> Option<Self>) -> Self
fn rewrite(&self, f: &impl Fn(Self) -> Option<Self>) -> Self
§fn cata<T>(&self, op: &impl Fn(Self, VecDeque<T>) -> T) -> T
fn cata<T>(&self, op: &impl Fn(Self, VecDeque<T>) -> T) -> T
Auto Trait Implementations§
impl<T> Freeze for Moo<T>
impl<T> RefUnwindSafe for Moo<T>where
Arc<T>: RefUnwindSafe,
impl<T> Send for Moo<T>
impl<T> Sync for Moo<T>
impl<T> Unpin for Moo<T>
impl<T> UnsafeUnpin for Moo<T>where
Arc<T>: UnsafeUnpin,
impl<T> UnwindSafe for Moo<T>where
Arc<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes