rust/src/test/run-pass/unsized-locals/by-value-trait-object-safety.rs

24 lines
403 B
Rust
Raw Normal View History

2018-09-11 10:19:09 -05:00
#![feature(unsized_locals)]
pub trait Foo {
fn foo(self) -> String;
}
struct A;
impl Foo for A {
fn foo(self) -> String {
format!("hello")
}
}
fn main() {
let x = *(Box::new(A) as Box<dyn Foo>);
assert_eq!(x.foo(), format!("hello"));
// I'm not sure whether we want this to work
let x = Box::new(A) as Box<dyn Foo>;
assert_eq!(x.foo(), format!("hello"));
2018-09-11 10:19:09 -05:00
}