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) -> Option<Moo<GroundDomain>>
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 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 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 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 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 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<T: Quine> Quine for Moo<T>
impl<T: Quine> Quine for Moo<T>
fn ctor_tokens(&self) -> TokenStream
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 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
impl<T: Eq> Eq for Moo<T>
impl<T> StructuralPartialEq for Moo<T>
Auto Trait Implementations§
impl<T> Freeze for Moo<T>
impl<T> RefUnwindSafe for Moo<T>where
T: RefUnwindSafe,
impl<T> Send for Moo<T>
impl<T> Sync for Moo<T>
impl<T> Unpin for Moo<T>
impl<T> UnwindSafe for Moo<T>where
T: RefUnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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 moreSource§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
random to avoid conflict with the new gen keyword in Rust 2024.Rng::random.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
random_rangeRng::random_range.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
RngCore to a RngReadAdapter.§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>
impl<T> CryptoRng for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<R> TryCryptoRng for R
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