From: Ian Jackson Date: Mon, 5 Jun 2023 15:46:48 +0000 (+0100) Subject: found before delete X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=8b15ede535eca515d1bd9d908b51a8ca62add192;p=rust-experiments.git found before delete --- diff --git a/src/main.rs b/src/main.rs index 966cf04..4b49bee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,78 +1,21 @@ -use std::any::*; -use std::sync::*; +use std::sync::mpsc; +use std::future::Future; +use std::pin::Pin; -pub trait Callable: Any { - type Output; - fn curry_fn() -> fn(Self, Args) -> Self::Output; -} -impl Callable<(A,)> for F where F: Fn(A) -> O + 'static { - type Output = O; - fn curry_fn() -> fn(Self, (A,)) -> O { |self_, (a,)| (self_)(a) } -} -impl Callable<(A,B)> for F where F: Fn(A,B) -> O + 'static { - type Output = O; - fn curry_fn() -> fn(Self, (A,B)) -> O { |self_, (a,b)| (self_)(a,b) } -} +async fn awaitpoint(_: ()) { } -pub trait Object: Any + Send + Sync {} -impl Object for String {} -pub trait MI: Any { - fn o_ti(&self) -> TypeId { TypeId::of::() } - fn call(&self, o: Arc, u: ()) -> usize; -} +async fn failure() { + let (_, rx) = mpsc::channel::<()>(); -impl MI for fn((Arc,())) -> usize { - fn call(&self, o: Arc, u: ()) -> usize { - (self)((Arc::downcast(o).unwrap(), u)) - } -} -impl MI for fn((Arc,)) -> usize { - fn call(&self, o: Arc, _u: ()) -> usize { - (self)((Arc::downcast(o).unwrap(),)) + while let Ok(event) = rx.recv() { + awaitpoint(event).await; } } -fn example(o: Arc) -> usize { o.len() } - -/* -struct K(F); - -const fn k>(f: F) -> K { - f -} - -&dyn MI { - move |o| f(o) - struct TE(&F); - impl MI for TE { - fn o_ti(&self) -> TypeId { TypeId::of::() } - fn call(&self, o: Arc) -> usize { - - } - } - -} - */ -/* -struct Thunk(C); - -impl MI for Thunk -where C: Fn((O,)) -> usize -{ - fn call(&self, o: Arc, u: ()) -> usize { - (self)((Arc::downcast(o).unwrap(),)) - } -} -*/ fn main() { - const CL: &dyn Any = { - &( - (&|t| Callable::curry_fn()(example, t)) - as fn(_) -> _ - ) - }; -//example.curry_fn(); -// let v: &dyn MI = k(example); - - println!("Hello, world!"); + let _: Pin + Send>> = Box::pin( + async { + failure().await; + } + ); }