Skip to content

Instantly share code, notes, and snippets.

@eholk
Created February 6, 2023 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eholk/6ab9914cd32fc265b66b517229c6ac06 to your computer and use it in GitHub Desktop.
Save eholk/6ab9914cd32fc265b66b517229c6ac06 to your computer and use it in GitHub Desktop.
#![feature(async_fn_in_trait, async_fn_in_dyn_trait, dyn_star)]
#![allow(incomplete_features)]
trait MyTrait {
async fn foo(&self, n: usize) -> i32;
fn bar(&self) -> i32;
}
impl MyTrait for i32 {
async fn foo(&self, n: usize) -> i32 {
n as i32
}
fn bar(&self) -> i32 {
*self
}
}
fn assert_dyn_star(_: dyn* std::future::Future<Output = i32>) {}
fn body(x: &dyn MyTrait) {
let g = x.bar();
let f = x.foo(g as usize);
assert_dyn_star(f);
}
fn main() {
let x = &0 as &dyn MyTrait;
body(x);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment