// Copyright 2021 Ian Jackson and contributors // SPDX-License-Identifier: GPL-3.0-or-later // There is NO WARRANTY. // This is a skeleton demonstrating a simple open-coded version // of the traits and types. #![allow(dead_code)] mod partial { #[derive(Debug,Clone,Copy)] pub struct Not; #[derive(Debug,Clone,Copy)] pub struct Ref; #[derive(Debug)] pub struct Mut; pub trait AdjPerm { type R; } #[allow(non_camel_case_types)] pub trait Pb { type Def_Not; type Def_Ref; type Def_Mut; type Fields; const FIELDS: Self::Fields; } } #[allow(dead_code)] // for here only struct AB<'c,DT> where DT: XT { a: usize, c: &'c str, d: DT, } trait XT { } impl XT for () { } #[allow(dead_code)] #[allow(non_camel_case_types)] /* as for AB */ struct AB__parts<'c,PA,PC,PD,DT> where DT: XT { a: AB__::F_a>, c: AB__::F_c>, d: AB__::F_d>, } impl<'c,DT> partial::Pb for AB<'c,DT> where DT: XT { type Def_Not = AB__parts<'c, partial::Not, partial::Not, partial::Not, DT>; type Def_Ref = AB__parts<'c, partial::Ref, partial::Ref, partial::Ref, DT>; type Def_Mut = AB__parts<'c, partial::Mut, partial::Mut, partial::Mut, DT>; type Fields = AB__::Fields; const FIELDS: AB__::Fields = AB__::FIELDS; } pub trait G { type Mut; } impl<'c,Fa,Fb,Fd,DT,NP> partial::AdjPerm for AB__parts<'c,Fa,Fb,Fd,DT> where AB<'c,DT>: partial::Pb, DT: XT { type R = AB__parts<'c, Fa, NP, Fd, DT>; } #[allow(dead_code)] #[allow(non_camel_case_types)] #[allow(non_snake_case)] #[allow(unused_imports)] pub /* as for AB */ mod AB__ { use std::marker::PhantomData; use super::partial::{self, Not, Ref, Mut, AdjPerm}; pub struct F_a { #[allow(dead_code)] p: P, t: PhantomData, s: PhantomData<*const S>, } pub struct F_c { #[allow(dead_code)] p: P, t: PhantomData, s: PhantomData<*const S>, } pub struct F_d { #[allow(dead_code)] p: P, t: PhantomData, s: PhantomData<*const S>, } pub struct Fields { pub a: usize } pub const FIELDS: Fields = Fields { a: 0, }; /* pub trait Field { type Not_a; type Ref_a; type Mut_a; type Not_b; type Ref_b; type Mut_b; } impl Field for super::AB__parts { type Not_a = super::AB__parts; type Ref_a = super::AB__parts; type Mut_a = super::AB__parts; type Not_b = super::AB__parts; type Ref_b = super::AB__parts; type Mut_b = super::AB__parts; }*/ // trait XXField { // type Fld_b; // } // pub struct KK; /* impl XXField for XField { type Fld_b = (); }*/ } //pub use AB__::Field; //type Next = Start::Fld_b; //const K: usize = AB::__field_a(); type Start = as partial::Pb>::Def_Not; type Next = as partial::Pb >::FIELDS.a } > >::R; #[allow(dead_code)] pub fn wat(_p: // &mut parts!(AB mut b) // &mut <::Def_Not as AB__::Field>::Mut_b () ) { // let _: &mut AB__parts = p; }