pub trait Mend<From> {
type Into: Layout;
// Required method
fn mend(self, from: &From) -> Self::Into;
}Expand description
Convert a layout to a stricter one.
§Design
A comment on the design space available for this trait.
(TODO: wrong) We require that the trait is
implemented for the type that is returned. If we required that the trait be implemented for
the receiver then this would restrict third-parties from using it to its full potential. In
particular, since Mend is a foreign trait the coherence rules make it impossible to specify:
TODO Terminology: https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html
impl<T> Mend<LocalType> for T {}TODO: rewrite this…
impl<T> Mend<T> for LocalType {}The forms of evolution that we want to keep open:
- Introduce a new form of mending between existing layouts. For example, a new color space transformation should be able to translate between existing types. Note that we will assume that in such a case the type parameters do not appear uncovered in the target or the source so that having either as the trait receiver (T0) allows this.
- An upgrader type should be able to mend a <T: LocalOrForeignTrait> into a chosen layout.
- TODO: When add a new layout type which mender types and targets do we want?
The exact form thus simply depends on expected use and the allow evolution for this crate. Consider in particular this coherence/SemVer rule:
Adding any impl with an uncovered type parameter is considered a major breaking change.
TODO
TODO: comment and consider &self.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".