Skip to content

Commit

Permalink
non-exhaustive enums
Browse files Browse the repository at this point in the history
  • Loading branch information
JieningYu committed Feb 22, 2024
1 parent 69f81d6 commit f08809f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ if-not-else = "warn"
if-then-some-else-none = "warn"
impl-trait-in-params = "warn"
macro-use-imports = "forbid"
exhaustive-enums = "warn"
1 change: 1 addition & 0 deletions crates/core/item/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub use Settings as ItemSettings;

/// Rarity of an item.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default)]
#[non_exhaustive]
pub enum Rarity {
/// Common rarity.
#[default]
Expand Down
1 change: 1 addition & 0 deletions crates/core/registry/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{key::Key, tag::TagKey};
/// Type holds a value that can be registered
/// in a registry.
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)]
pub enum Entry<'a, K, T> {
/// Holds the value directly.
Direct(T),
Expand Down
2 changes: 2 additions & 0 deletions crates/core/state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ where

/// Error type for state operations.
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
/// The property was not found in the state.
PropertyNotFound(String),
Expand Down Expand Up @@ -394,6 +395,7 @@ impl std::error::Error for Error {}

/// Cell that can be either an [`Arc`] or a borrowed reference.
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)]
pub enum MaybeArc<'a, T> {
/// The reference-counted variant.
Arc(Arc<T>),
Expand Down
1 change: 1 addition & 0 deletions crates/core/text/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use rimecraft_fmt::Formatting;

/// An error type for the text module.
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
/// The given formatting does not contains a color.
FormattingWithoutColor(Formatting),
Expand Down
2 changes: 2 additions & 0 deletions crates/core/world/palette/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct Palette<L, T> {

/// The strategy to use for the palette.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive] // New strategies may be added in the future.
pub enum Strategy {
/// A palette that only holds a unique entry.
#[doc(alias = "SingleValue")]
Expand Down Expand Up @@ -418,6 +419,7 @@ where

/// Error type for palette operations.
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
/// The palette is uninitialized.
Uninitialized,
Expand Down
2 changes: 2 additions & 0 deletions crates/util/fmt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ macro_rules! formattings {
serde(rename_all = "snake_case")
)]
#[doc(alias = "ChatFormatting")]
#[non_exhaustive]
pub enum Formatting {
$(#[doc = "The formatting."] $i),*
}
Expand Down Expand Up @@ -217,6 +218,7 @@ formattings! {
/// An error returned when parsing a formatting.
#[derive(Debug)]
#[allow(variant_size_differences)]
#[non_exhaustive]
pub enum Error {
/// No matching color index found.
InvalidColorIndex(i32),
Expand Down
1 change: 1 addition & 0 deletions crates/util/identifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ where

/// Errors that may occur when parsing an identifier.
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)]
pub enum FromStrError<EN, EP> {
/// An error occurred when parsing the namespace.
Namespace(EN),
Expand Down

0 comments on commit f08809f

Please sign in to comment.