Skip to content

Commit

Permalink
refactor: change more masking strategy structs to no-variant enums
Browse files Browse the repository at this point in the history
as per #1973
  • Loading branch information
nain-F49FF806 committed Nov 27, 2023
1 parent a98f1b9 commit f7549fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/cards/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'de> Deserialize<'de> for CardNumber {
}
}

pub struct CardNumberStrategy;
pub enum CardNumberStrategy {}

impl<T> Strategy<T> for CardNumberStrategy
where
Expand Down
6 changes: 3 additions & 3 deletions crates/masking/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use crate::{strategy::Strategy, PeekInterface};
/// To get access to value use method `expose()` of trait [`crate::ExposeInterface`].
///
/// ## Masking
/// Use the [`crate::strategy::Strategy`] trait to implement a masking strategy on a unit struct
/// and pass the unit struct as a second generic parameter to [`Secret`] while defining it.
/// Use the [`crate::strategy::Strategy`] trait to implement a masking strategy on a zero-variant
/// enum and pass this enum as a second generic parameter to [`Secret`] while defining it.
/// [`Secret`] will take care of applying the masking strategy on the inner secret when being
/// displayed.
///
Expand All @@ -24,7 +24,7 @@ use crate::{strategy::Strategy, PeekInterface};
/// use masking::Secret;
/// use std::fmt;
///
/// struct MyStrategy;
/// enum MyStrategy {}
///
/// impl<T> Strategy<T> for MyStrategy
/// where
Expand Down
4 changes: 2 additions & 2 deletions crates/masking/src/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub trait Strategy<T> {
}

/// Debug with type
pub struct WithType;
pub enum WithType {}

impl<T> Strategy<T> for WithType {
fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -18,7 +18,7 @@ impl<T> Strategy<T> for WithType {
}

/// Debug without type
pub struct WithoutType;
pub enum WithoutType {}

impl<T> Strategy<T> for WithoutType {
fn fmt(_: &T, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down

0 comments on commit f7549fd

Please sign in to comment.