Skip to content

Commit

Permalink
Pleasing clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
8192K committed Feb 16, 2024
1 parent 5dc4561 commit c8a91e1
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ impl RedisLoggerConfigBuilder {
CONN: ConnectionLike + Send + Sync,
PUBSUB: PubSubEncoder,
{
if channels.is_empty() {
Self::panic_if_channels_not_set();
}
Self::check_args(!channels.is_empty());
RedisLoggerConfig {
connection: Mutex::new(connection),
channels: Some((channels, encoder)),
Expand Down Expand Up @@ -263,9 +261,7 @@ impl RedisLoggerConfigBuilder {
where
CONN: ConnectionLike + Send + Sync,
{
if channels.is_empty() {
Self::panic_if_channels_not_set();
}
Self::check_args(!channels.is_empty());
RedisLoggerConfig {
connection: Mutex::new(connection),
channels: Some((channels, DefaultPubSubEncoder::new())),
Expand Down Expand Up @@ -297,9 +293,7 @@ impl RedisLoggerConfigBuilder {
CONN: ConnectionLike + Send + Sync,
STREAM: StreamEncoder,
{
if streams.is_empty() {
Self::panic_if_channels_not_set();
}
Self::check_args(!streams.is_empty());
RedisLoggerConfig {
connection: Mutex::new(connection),
channels: None,
Expand Down Expand Up @@ -331,9 +325,7 @@ impl RedisLoggerConfigBuilder {
where
CONN: ConnectionLike + Send + Sync,
{
if streams.is_empty() {
Self::panic_if_channels_not_set();
}
Self::check_args(!streams.is_empty());
RedisLoggerConfig {
connection: Mutex::new(connection),
channels: None,
Expand Down Expand Up @@ -370,9 +362,7 @@ impl RedisLoggerConfigBuilder {
PUBSUB: PubSubEncoder,
STREAM: StreamEncoder,
{
if channels.is_empty() && streams.is_empty() {
Self::panic_if_channels_not_set();
}
Self::check_args(!channels.is_empty() && !streams.is_empty());
RedisLoggerConfig {
connection: Mutex::new(connection),
channels: Some((channels, pubsub_encoder)),
Expand Down Expand Up @@ -406,17 +396,15 @@ impl RedisLoggerConfigBuilder {
where
CONN: ConnectionLike + Send + Sync,
{
if channels.is_empty() && streams.is_empty() {
Self::panic_if_channels_not_set();
}
Self::check_args(!channels.is_empty() && !streams.is_empty());
RedisLoggerConfig {
connection: Mutex::new(connection),
channels: Some((channels, DefaultPubSubEncoder::new())),
streams: Some((streams, DefaultStreamEncoder::new())),
}
}

const fn panic_if_channels_not_set() {
panic!("Channels not set in RedisLogger. Set at least one pub/sub channel and/or one stream channel.");
const fn check_args(value: bool) {
assert!(value, "Channels not set in RedisLogger. Set at least one pub/sub channel and/or one stream channel.");
}
}

0 comments on commit c8a91e1

Please sign in to comment.