Skip to content

Commit

Permalink
Rollup merge of rust-lang#92568 - Mark-Simulacrum:non-exhaustive-vari…
Browse files Browse the repository at this point in the history
…ant-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 rust-lang#73662
  • Loading branch information
matthiaskrgr authored Jan 5, 2022
2 parents 2649d0f + 57b59af commit 865442a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
/// ```
Expand Down

0 comments on commit 865442a

Please sign in to comment.