Skip to content

Commit

Permalink
Minimize 52893
Browse files Browse the repository at this point in the history
  • Loading branch information
fanninpm committed Dec 19, 2020
1 parent f418aba commit 36e9c56
Showing 1 changed file with 15 additions and 39 deletions.
54 changes: 15 additions & 39 deletions ices/52893.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
impl<P, T, Name, F, OLIST: HList, X, Y, FINAL> AddClass<Name, F> for Class<P, T>
impl<P, T, Name, F, OLIST, FINAL> AddClass<Name, F> for Class<P, T>
where
Self: At<Name>,
P: Default,
X: Entry,
T: Push<(P, F)>,
<X as Entry>::Data: Fn(Y) -> Class<P, OLIST>,
<Class<P, T> as At<Name>>::AtRes: Push<(P, F)>,
<<Class<P, T> as At<Name>>::AtRes as Push<(P, F)>>::PushRes: for<'this> ToRef<'this, Output=HCons<X, Y>> + Push<OLIST>,
<<<Class<P, T> as At<Name>>::AtRes as Push<(P, F)>>::PushRes as Push<OLIST>>::PushRes: Entry<Data=FINAL>
<Class<P, T> as At<Name>>::AtRes: Push<F>,
<<Class<P, T> as At<Name>>::AtRes as Push<F>>::PushRes:
ToRef<Output = Class<P, OLIST>> + Push<OLIST>,
<<<Class<P, T> as At<Name>>::AtRes as Push<F>>::PushRes as Push<OLIST>>::PushRes:
Entry<Data = FINAL>,
{
type Output = Class<P, FINAL>;

fn init(self, func: F) -> Self::Output {
let builder = self.at();
let builder = builder.push((P::default(), func));
let output = {
let refs = builder.to_ref();
let func = refs.head.borrow_data();
func(refs.tail)
};
let final_data = builder.push(output);
Class {
path: P::default(),
data: final_data.get_data()
}
let builder = builder.push(func);
let output = builder.to_ref();
builder.push(output)
}
}

Expand All @@ -44,48 +34,34 @@ trait Push<T> {
fn push(self, other: T) -> Self::PushRes;
}

trait AddClass<Name, F>: At<Name> {
trait AddClass<Name, F> {
type Output;

fn init(self, func: F) -> Self::Output;
}

trait Entry {
type Data;

fn get_data(self) -> Self::Data;
fn borrow_data(&self) -> &Self::Data;
}

impl<P: HList, T> Class<P, T> {
impl<P, T> Class<P, T> {
fn with<Name, F>(self, constructor: F) -> <Self as AddClass<Name, F>>::Output
where
Self: AddClass<Name, F>,
{
self.init(constructor)
loop {}
}

fn from<F>(self, constructor: F) -> <Self as AddClass<P, F>>::Output
where
Self: AddClass<P, F>,
{
self.init(constructor)
loop {}
}
}

fn main() {
println!("Hello, world!");
}

/// Below structs are to bypass the original frunk requirements
pub trait HList {}
pub struct HCons<H, T> {
pub head: H,
pub tail: T,
}

pub trait ToRef<'a> {
trait ToRef {
type Output;

fn to_ref(&'a self) -> Self::Output;
fn to_ref(&self) -> Self::Output;
}

0 comments on commit 36e9c56

Please sign in to comment.