impl_inheritance/
lib.rs

1#![feature(specialization)]
2pub use impl_inheritance_macros::*;
3
4//todo: replace with ! when stable and != Infallible
5pub type Placeholder = std::convert::Infallible;
6
7pub trait SuperBorrow<T> 
8where T: ? Sized
9{
10    fn super_ref(&self) -> & T;
11    fn super_ref_mut(& mut self) -> & mut T;
12}
13
14pub trait IsSuperBorrowableTo<T>
15where T : ?Sized {
16    fn get_part(x : &T) -> &Self;
17    fn get_part_mut(x :& mut T) -> & mut Self;
18}
19
20impl <T,X> IsSuperBorrowableTo<T> for X 
21where T : SuperBorrow<X> {
22    fn get_part(x : &T) -> &X {
23        x.super_ref()
24    }
25    fn get_part_mut(x :& mut T) -> & mut X
26    {
27        x.super_ref_mut()
28    }
29}
30
31pub trait SuperType {
32    type SupType;
33}
34
35impl SuperType for Placeholder {
36    type SupType = Placeholder;
37}
38
39expand_constraits_def!();
40