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

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

18 lines
450 B
Rust
Raw Normal View History

// run-pass
2018-03-14 22:30:06 -05:00
// ignore-pretty `dyn ::foo` parses differently in the current edition
2018-02-24 20:02:33 -06:00
2017-10-10 09:33:19 -05: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 14:45:10 -06:00
let _: &dyn (Display) = &BYTE;
let _: &dyn (::std::fmt::Display) = &BYTE;
2017-10-10 09:33:19 -05:00
let xstr = format!("{}", x);
let ystr = format!("{}", y);
assert_eq!(xstr, "33");
assert_eq!(ystr, "33");
}