We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b05bb29 commit 571b0feCopy full SHA for 571b0fe
library/core/src/mem/mod.rs
@@ -1118,6 +1118,11 @@ impl<T> fmt::Debug for Discriminant<T> {
1118
///
1119
/// [Reference]: ../../reference/items/enumerations.html#custom-discriminant-values-for-fieldless-enumerations
1120
1121
+/// The value of a [`Discriminant<T>`] 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<A>>` and `Discriminant<Foo<B>>` might be incompatible.
1125
+///
1126
/// # Examples
1127
1128
/// This can be used to compare enums that carry data, while disregarding
0 commit comments