Centril / rfc-trait-parametric-polymorphism

Planning, scheming and designing of {-# LANGAUGE ConstraintKinds #-} for Rust
11 stars 0 forks source link

A better abstraction over trait objects + universal composition-for-inheritance trait #14

Open danielhenrymantilla opened 5 years ago

danielhenrymantilla commented 5 years ago

One of the greatest usages would be to have a correct abstraction over trait objects:

struct TraitObject<trait Trait> {
    ptr: *mut (),
    vtable: *const Trait::VTable,
}

with a compiler defined type VTable defined for all traits.


With my WIP crate https://docs.rs/inheritance, what the proc-macro generates for the trait that we want to inherit from (e.g., Point), is a new trait

trait InheritsPoint {
    type Parent : Point;
    // projections from Self to Self::Parent
}

Instead, having

trait Inherits<trait Trait> {
    type Parent : Trait;
    // projections from Self to Self::Parent
}

as in the Map example from the README.md would make this cleaner.


(Post-it note for @Centril )