@@ -1625,9 +1625,9 @@ mod dyn_keyword {}
1625
1625
/// The [Rust equivalent of a C-style union][union].
1626
1626
///
1627
1627
/// A `union` looks like a [`struct`] in terms of declaration, but all of its
1628
- /// fields exist simultaneously , superimposed over one another. For instance,
1628
+ /// fields exist in the same memory , superimposed over one another. For instance,
1629
1629
/// if we wanted some bits in memory that we sometimes interpret as a `u32` and
1630
- /// sometimes as an `f32`, we would write:
1630
+ /// sometimes as an `f32`, we could write:
1631
1631
///
1632
1632
/// ```rust
1633
1633
/// union IntOrFloat {
@@ -1647,6 +1647,7 @@ mod dyn_keyword {}
1647
1647
///
1648
1648
/// It is possible to use pattern matching on `union`s. A single field name must
1649
1649
/// be used and it must match the name of one of the `union`'s field.
1650
+ /// Like reading from a `union`, pattern matching on a `union` requires `unsafe`.
1650
1651
///
1651
1652
/// ```rust
1652
1653
/// union IntOrFloat {
@@ -1658,17 +1659,17 @@ mod dyn_keyword {}
1658
1659
///
1659
1660
/// unsafe {
1660
1661
/// match u {
1661
- /// IntOrFloat { i: 10 } => println!("Found exactly ten !"),
1662
- /// // The field name is used to deduce the type
1662
+ /// IntOrFloat { i: 10 } => println!("Found exactly ten!"),
1663
+ /// // Matching the field `f` provides an `f32`.
1663
1664
/// IntOrFloat { f } => println!("Found f = {} !", f),
1664
1665
/// }
1665
1666
/// }
1666
1667
/// ```
1667
1668
///
1668
1669
/// # References to union fields
1669
1670
///
1670
- /// All fields in a union are all at the same place in memory which means
1671
- /// borrowing one borrows all of them , for the same duration :
1671
+ /// All fields in a ` union` are all at the same place in memory which means
1672
+ /// borrowing one borrows the entire `union` , for the same lifetime :
1672
1673
///
1673
1674
/// ```rust,compile_fail,E0502
1674
1675
/// union IntOrFloat {
0 commit comments