]> git.lizzy.rs Git - rust.git/blob - src/test/ui/union/union-trait-impl.rs
Merge commit '3e7c6dec244539970b593824334876f8b6ed0b18' into clippyup
[rust.git] / src / test / ui / union / union-trait-impl.rs
1 // run-pass
2
3 use std::fmt;
4
5 union U {
6     a: u8
7 }
8
9 impl fmt::Display for U {
10     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
11         unsafe { write!(f, "Oh hai {}", self.a) }
12     }
13 }
14
15 fn main() {
16     assert_eq!(U { a: 2 }.to_string(), "Oh hai 2");
17 }