pub trait MachineConstruction<E, RuntimeT: Send>: Sized {
// Required method
fn query_cow<R: ClarifiedCerrMerging + 'static + Send>(
self,
closure: impl for<'a> FnOnce(Cow<'a, RuntimeT>) -> Machine<R> + 'static + Send,
) -> Machine<R>;
// Provided methods
fn query<R: ClarifiedCerrMerging + 'static + Send>(
self,
closure: impl FnOnce(RuntimeT) -> Machine<R> + 'static + Send,
) -> Machine<R>
where RuntimeT: Clone { ... }
fn query_ref<R: ClarifiedCerrMerging + 'static + Send>(
self,
closure: impl for<'a> FnOnce(&'a RuntimeT) -> Machine<R> + 'static + Send,
) -> Machine<R>
where RuntimeT: Clone + CheapBorrowFromAny { ... }
}Required Methods§
fn query_cow<R: ClarifiedCerrMerging + 'static + Send>( self, closure: impl for<'a> FnOnce(Cow<'a, RuntimeT>) -> Machine<R> + 'static + Send, ) -> Machine<R>
Provided Methods§
fn query<R: ClarifiedCerrMerging + 'static + Send>(
self,
closure: impl FnOnce(RuntimeT) -> Machine<R> + 'static + Send,
) -> Machine<R>where
RuntimeT: Clone,
fn query_ref<R: ClarifiedCerrMerging + 'static + Send>(
self,
closure: impl for<'a> FnOnce(&'a RuntimeT) -> Machine<R> + 'static + Send,
) -> Machine<R>where
RuntimeT: Clone + CheapBorrowFromAny,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<E, T, RuntimeT> MachineConstruction<E, Option<RuntimeT>> for Option<T>
WARNING: this always clones
A solution, that involves work, could be to replace Cow in the closure signature
with an associated type, but this would prevent inference.
This is left open as most of the types in this project are cheap to clone
impl<E, T, RuntimeT> MachineConstruction<E, Option<RuntimeT>> for Option<T>
WARNING: this always clones
A solution, that involves work, could be to replace Cow in the closure signature
with an associated type, but this would prevent inference.
This is left open as most of the types in this project are cheap to clone
The problem is that a reference &RuntimeT can only be converted to an owned
value of type Option<&RuntimeT> and not to &Option<RuntimeT> what would be
needed for Cow. The other direction is possible using Option::as_ref.
This direction seems to be impossible so the only solution would be a new trait with
new methods specifically for Option.