Rollup merge of #92568 - Mark-Simulacrum:non-exhaustive-variant-count, r=the8472

Add note about non_exhaustive to variant_count

Since `variant_count` isn't returning something opaque, I thought it makes sense to explicitly call out that its return value may change for some enums.

cc #73662
This commit is contained in:
Eric Huss 2022-01-07 20:20:59 -08:00 committed by GitHub
commit 0bd7e2ff2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1045,6 +1045,10 @@ pub const fn discriminant<T>(v: &T) -> Discriminant<T> {
/// return value is unspecified. Equally, if `T` is an enum with more variants than `usize::MAX`
/// the return value is unspecified. Uninhabited variants will be counted.
///
/// Note that an enum may be expanded with additional variants in the future
/// as a non-breaking change, for example if it is marked `#[non_exhaustive]`,
/// which will change the result of this function.
///
/// # Examples
///
/// ```