pub trait TypeMapping {
type InV<'c>: Clone;
type OutV<'c>;
type SumOutV<'c>;
type FuncOutV<'c>;
// Required methods
fn map_sum_type<'c>(
&self,
sum_type: &HugrSumType,
inv: Self::InV<'c>,
variants: impl IntoIterator<Item = Vec<Self::OutV<'c>>>,
) -> Result<Self::SumOutV<'c>>;
fn map_function_type<'c>(
&self,
function_type: &HugrFuncType,
inv: Self::InV<'c>,
inputs: impl IntoIterator<Item = Self::OutV<'c>>,
outputs: impl IntoIterator<Item = Self::OutV<'c>>,
) -> Result<Self::FuncOutV<'c>>;
fn sum_into_out<'c>(&self, sum: Self::SumOutV<'c>) -> Self::OutV<'c>;
fn func_into_out<'c>(&self, sum: Self::FuncOutV<'c>) -> Self::OutV<'c>;
// Provided method
fn default_out<'c>(
&self,
inv: Self::InV<'c>,
hugr_type: &HugrType,
) -> Result<Self::OutV<'c>> { ... }
}
Expand description
Defines a mapping from HugrType
to OutV
;
Required Associated Types§
Sourcetype SumOutV<'c>
type SumOutV<'c>
The target type when mapping from HugrSumType
s. This type must be
convertible to OutV
via sum_into_out
.
Sourcetype FuncOutV<'c>
type FuncOutV<'c>
The target type when mapping from HugrFuncType
s. This type must be
convertible to OutV
via func_into_out
.
Required Methods§
Sourcefn map_sum_type<'c>(
&self,
sum_type: &HugrSumType,
inv: Self::InV<'c>,
variants: impl IntoIterator<Item = Vec<Self::OutV<'c>>>,
) -> Result<Self::SumOutV<'c>>
fn map_sum_type<'c>( &self, sum_type: &HugrSumType, inv: Self::InV<'c>, variants: impl IntoIterator<Item = Vec<Self::OutV<'c>>>, ) -> Result<Self::SumOutV<'c>>
Returns the result of the mapping on sum_type
, with auxiliary data
inv
, and when the result of mapping all fields of all variants is
given by variants
.
Sourcefn map_function_type<'c>(
&self,
function_type: &HugrFuncType,
inv: Self::InV<'c>,
inputs: impl IntoIterator<Item = Self::OutV<'c>>,
outputs: impl IntoIterator<Item = Self::OutV<'c>>,
) -> Result<Self::FuncOutV<'c>>
fn map_function_type<'c>( &self, function_type: &HugrFuncType, inv: Self::InV<'c>, inputs: impl IntoIterator<Item = Self::OutV<'c>>, outputs: impl IntoIterator<Item = Self::OutV<'c>>, ) -> Result<Self::FuncOutV<'c>>
Returns the result of the mapping on function_type
, with auxiliary data
inv
, and when the result of mapping all inputs is given by inputs
and the result of mapping all outputs is given by outputs
.
Sourcefn sum_into_out<'c>(&self, sum: Self::SumOutV<'c>) -> Self::OutV<'c>
fn sum_into_out<'c>(&self, sum: Self::SumOutV<'c>) -> Self::OutV<'c>
Infallibly convert from the result of map_sum_type
to the result of
the mapping.
Sourcefn func_into_out<'c>(&self, sum: Self::FuncOutV<'c>) -> Self::OutV<'c>
fn func_into_out<'c>(&self, sum: Self::FuncOutV<'c>) -> Self::OutV<'c>
Infallibly convert from the result of map_functype
to the result of
the mapping.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.