Add test case for calling methods on dyn* object
This commit is contained in:
parent
c5441acf67
commit
48e7f24804
25
src/test/ui/async-await/dyn-star-trait-method.rs
Normal file
25
src/test/ui/async-await/dyn-star-trait-method.rs
Normal file
@ -0,0 +1,25 @@
|
||||
// run-pass
|
||||
#![feature(async_fn_in_traits)]
|
||||
|
||||
trait Foo {
|
||||
fn get(&self) -> usize;
|
||||
}
|
||||
|
||||
impl Foo for usize {
|
||||
fn get(&self) -> usize {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
fn invoke_dyn_star(i: dyn* Foo) -> usize {
|
||||
i.get()
|
||||
}
|
||||
|
||||
fn make_and_invoke_dyn_star(i: usize) -> usize {
|
||||
let dyn_i: dyn* Foo = i as dyn* Foo;
|
||||
invoke_dyn_star(dyn_i)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("{}", make_and_invoke_dyn_star(42));
|
||||
}
|
Loading…
Reference in New Issue
Block a user