Clarify stability guarantee for lifetimes in enum discriminants · rust-lang/rust@571b0fe (original) (raw)

Original file line number Diff line number Diff line change
@@ -1118,6 +1118,11 @@ impl fmt::Debug for Discriminant {
1118 1118 ///
1119 1119 /// [Reference]: ../../reference/items/enumerations.html#custom-discriminant-values-for-fieldless-enumerations
1120 1120 ///
1121 +/// The value of a [`Discriminant`] is independent of any *lifetimes* in `T`. As such, reading
1122 +/// or writing a `Discriminant<Foo<'a>>` as a `Discriminant<Foo<'b>>` (whether via [`transmute`] or
1123 +/// otherwise) is always sound. Note that this is **not** true for other kinds of generic
1124 +/// parameters; `Discriminant<Foo>` and `Discriminant<Foo>` might be incompatible.
1125 +///
1121 1126 /// # Examples
1122 1127 ///
1123 1128 /// This can be used to compare enums that carry data, while disregarding