Created
February 6, 2023 19:48
-
-
Save eholk/6ab9914cd32fc265b66b517229c6ac06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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