os-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-24 18:02:33 -08:00
2017-10-10 17:33:19 +03: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 12:45:10 -08:00
let _: &dyn (Display) = &BYTE;
let _: &dyn (::std::fmt::Display) = &BYTE;
2017-10-10 17:33:19 +03:00
let xstr = format!("{}", x);
let ystr = format!("{}", y);
assert_eq!(xstr, "33");
assert_eq!(ystr, "33");
}