rust/tests/ui/traits/dyn-trait.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
380 B
Rust
Raw Normal View History

//@ run-pass
2018-02-25 02:02:33 +00:00
2017-10-10 14:33:19 +00:00
use std::fmt::Display;
static BYTE: u8 = 33;
fn main() {
let x: &(dyn 'static + Display) = &BYTE;
let y: Box<dyn Display + 'static> = Box::new(BYTE);
2018-02-23 20:45:10 +00:00
let _: &dyn (Display) = &BYTE;
let _: &dyn (::std::fmt::Display) = &BYTE;
2017-10-10 14:33:19 +00:00
let xstr = format!("{}", x);
let ystr = format!("{}", y);
assert_eq!(xstr, "33");
assert_eq!(ystr, "33");
}