// Copyright (c) 2023 Google LLC // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(incomplete_features)] #![feature(return_type_notation)] use std::iter; use trait_transformer::trait_transformer; #[trait_transformer(SendIntFactory: Send )] trait IntFactory { async fn make(&self) -> i32; // ..or.. fn stream(&self) -> impl Iterator; fn call(&self) -> u32; } fn thing(factory: impl SendIntFactory + 'static) { tokio::task::spawn(async move { factory.make().await; }); } struct MyFactory; impl IntFactory for MyFactory { async fn make(&self) -> i32 { todo!() } fn stream(&self) -> impl Iterator { iter::empty() } fn call(&self) -> u32 { 0 } } // impl SendIntFactory for MyFactory {} fn main() { let my_factory = MyFactory; thing(my_factory); }