2024-04-15 23:01:02 +02:00
|
|
|
//@ compile-flags: -Cdebuginfo=2
|
2025-01-23 11:25:12 +00:00
|
|
|
#![allow(sized_hierarchy_migration)]
|
|
|
|
|
#![feature(sized_hierarchy)] // added to keep parameters unconstrained
|
2024-04-15 23:01:02 +02:00
|
|
|
|
2025-01-23 11:25:12 +00:00
|
|
|
pub trait Functor: std::marker::PointeeSized
|
2024-04-15 23:01:02 +02:00
|
|
|
{
|
|
|
|
|
type With<T>: Functor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct IdFunctor<T>(T);
|
|
|
|
|
impl<T> Functor for IdFunctor<T> {
|
|
|
|
|
type With<T2> = IdFunctor<T2>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T> Functor for Vec<T> {
|
|
|
|
|
type With<T2> = Vec<T2> ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct Compose<F1, F2, T>(F1::With<F2::With<T>>)
|
|
|
|
|
where
|
2025-01-23 11:25:12 +00:00
|
|
|
F1: Functor + std::marker::PointeeSized,
|
|
|
|
|
F2: Functor + std::marker::PointeeSized;
|
2024-04-15 23:01:02 +02:00
|
|
|
|
|
|
|
|
impl<F1, F2, T> Functor for Compose<F1, F2, T>
|
|
|
|
|
where
|
2025-01-23 11:25:12 +00:00
|
|
|
F1: Functor + std::marker::PointeeSized,
|
|
|
|
|
F2: Functor + std::marker::PointeeSized,
|
2024-04-15 23:01:02 +02:00
|
|
|
{
|
|
|
|
|
type With<T2> = F1::With<F2::With<T2>> ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub enum Value<F>
|
|
|
|
|
where
|
2025-01-23 11:25:12 +00:00
|
|
|
F: Functor + std::marker::PointeeSized,
|
2024-04-15 23:01:02 +02:00
|
|
|
{
|
|
|
|
|
SignedInt(*mut F::With<i64>),
|
|
|
|
|
Array(*mut Value<Compose<F, Vec<()>, ()>>),
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let x: Value<IdFunctor<()>> = Value::SignedInt(&mut IdFunctor(1));
|
|
|
|
|
}
|