mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
18 lines
385 B
Rust
18 lines
385 B
Rust
mod m {
|
|
pub union U {
|
|
pub a: u8,
|
|
pub(super) b: u8,
|
|
c: u8,
|
|
}
|
|
}
|
|
|
|
fn main() { unsafe {
|
|
let u = m::U { a: 0 }; // OK
|
|
let u = m::U { b: 0 }; // OK
|
|
let u = m::U { c: 0 }; //~ ERROR field `c` of union `U` is private
|
|
|
|
let m::U { a } = u; // OK
|
|
let m::U { b } = u; // OK
|
|
let m::U { c } = u; //~ ERROR field `c` of union `U` is private
|
|
}}
|