Skip to main content

TypeTransformer

Trait TypeTransformer 

Source
pub trait TypeTransformer {
    type Err: Error + From<SignatureError>;

    // Required method
    fn apply_custom(
        &self,
        t: &CustomType,
    ) -> Result<Option<TypeBase<NoRV>>, Self::Err>;
}
Expand description

A transformation that can be applied to a Type or TypeArg.

More general in some ways than a Substitution: can fail with a Self::Err, may change TypeBound::Copyable to TypeBound::Linear, and applies to arbitrary extension types rather than type variables.

Required Associated Types§

Source

type Err: Error + From<SignatureError>

Error returned when a CustomType cannot be transformed, or a type containing it (e.g. if changing a runtime type from copyable to linear invalidates a parameterized type).

Required Methods§

Source

fn apply_custom( &self, t: &CustomType, ) -> Result<Option<TypeBase<NoRV>>, Self::Err>

Applies the transformation to an extension type.

Note that if the CustomType has type arguments, these will not have been transformed first (this might not produce a valid type due to changes in TypeBound).

Returns a type to use instead, or None to indicate no change (in which case, the TypeArgs will be transformed instead. To prevent transforming the arguments, return t.clone().into().)

Implementors§