Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
Signed-off-by: gruebel <[email protected]>
  • Loading branch information
gruebel committed Aug 2, 2024
1 parent 2c926d8 commit 233c02e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
11 changes: 6 additions & 5 deletions src/evaluation/details.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::fmt::{Display, Formatter};

use crate::EvaluationError;

Expand Down Expand Up @@ -68,9 +69,9 @@ pub enum EvaluationReason {
Other(String),
}

impl ToString for EvaluationReason {
fn to_string(&self) -> String {
match self {
impl Display for EvaluationReason {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let reason = match self {
Self::Static => "STATIC",
Self::Default => "DEFAULT",
Self::TargetingMatch => "TARGETING_MATCH",
Expand All @@ -80,8 +81,8 @@ impl ToString for EvaluationReason {
Self::Unknown => "UNKNOWN",
Self::Error => "ERROR",
Self::Other(reason) => reason.as_str(),
}
.to_string()
};
write!(f, "{reason}")
}
}

Expand Down
24 changes: 13 additions & 11 deletions src/evaluation/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// EvaluationError
// ============================================================

use std::fmt::{Display, Formatter};
use typed_builder::TypedBuilder;

/// Struct representing error
Expand Down Expand Up @@ -44,16 +45,17 @@ pub enum EvaluationErrorCode {
General(String),
}

impl ToString for EvaluationErrorCode {
fn to_string(&self) -> String {
match self {
Self::ProviderNotReady => "PROVIDER_NOT_READY".to_string(),
Self::FlagNotFound => "FLAG_NOT_FOUND".to_string(),
Self::ParseError => "PARSE_ERROR".to_string(),
Self::TypeMismatch => "TYPE_MISMATCH".to_string(),
Self::TargetingKeyMissing => "TARGETING_KEY_MISSING".to_string(),
Self::InvalidContext => "INVALID_CONTEXT".to_string(),
Self::General(message) => message.clone(),
}
impl Display for EvaluationErrorCode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let code = match self {
Self::ProviderNotReady => "PROVIDER_NOT_READY",
Self::FlagNotFound => "FLAG_NOT_FOUND",
Self::ParseError => "PARSE_ERROR",
Self::TypeMismatch => "TYPE_MISMATCH",
Self::TargetingKeyMissing => "TARGETING_KEY_MISSING",
Self::InvalidContext => "INVALID_CONTEXT",
Self::General(message) => message,
};
write!(f, "{code}")
}
}
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
#![warn(missing_docs)]
#![warn(clippy::pedantic)]
#![allow(clippy::doc_markdown)]
#![allow(clippy::implicit_hasher)]
#![allow(clippy::manual_let_else)]
#![allow(clippy::missing_errors_doc)]
#![allow(clippy::missing_panics_doc)]
#![allow(clippy::module_inception)]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::must_use_candidate)]
#![allow(clippy::new_without_default)]
#![allow(clippy::struct_excessive_bools)]
#![allow(clippy::too_many_lines)]
#![allow(clippy::uninlined_format_args)]

/// The OpenFeature API and client.
mod api;
Expand Down

0 comments on commit 233c02e

Please sign in to comment.