Skip to content

Commit efcb864

Browse files
committed
Improve readability of feature flags in code
1 parent a2ac525 commit efcb864

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

src/clients/mod.rs

+35-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
#[cfg(any(feature = "mailersend", feature = "terminal", feature = "smtp", feature = "memory", feature = "document-features"))]
1+
#[cfg(any(
2+
feature = "mailersend",
3+
feature = "terminal",
4+
feature = "smtp",
5+
feature = "memory",
6+
feature = "document-features"
7+
))]
28
use crate::configuration::EmailConfiguration;
3-
#[cfg(any(feature = "mailersend", feature = "terminal", feature = "smtp", feature = "memory", feature = "document-features"))]
9+
#[cfg(any(
10+
feature = "mailersend",
11+
feature = "terminal",
12+
feature = "smtp",
13+
feature = "memory",
14+
feature = "document-features"
15+
))]
416
use crate::traits::EmailTrait;
517

618
#[cfg_attr(docsrs, doc(cfg(feature = "smtp")))]
@@ -19,7 +31,13 @@ pub mod terminal;
1931
#[cfg(feature = "mailersend")]
2032
pub mod mailersend;
2133

22-
#[cfg(any(feature = "mailersend", feature = "terminal", feature = "smtp", feature = "memory", feature = "document-features"))]
34+
#[cfg(any(
35+
feature = "mailersend",
36+
feature = "terminal",
37+
feature = "smtp",
38+
feature = "memory",
39+
feature = "document-features"
40+
))]
2341
///`EmailClient` Enum representing different types of email clients.
2442
///Currently supported email clients: SMTP, Terminal, Memory.
2543
///
@@ -97,7 +115,13 @@ impl Default for EmailClient {
97115
}
98116
}
99117

100-
#[cfg(any(feature = "mailersend", feature = "terminal", feature = "smtp", feature = "memory", feature = "document-features"))]
118+
#[cfg(any(
119+
feature = "mailersend",
120+
feature = "terminal",
121+
feature = "smtp",
122+
feature = "memory",
123+
feature = "document-features"
124+
))]
101125
pub fn get_email_client(configuration: EmailConfiguration) -> EmailClient {
102126
match configuration {
103127
#[cfg(feature = "terminal")]
@@ -115,7 +139,13 @@ pub fn get_email_client(configuration: EmailConfiguration) -> EmailClient {
115139
}
116140
}
117141

118-
#[cfg(any(feature = "mailersend", feature = "terminal", feature = "smtp", feature = "memory", feature = "document-features"))]
142+
#[cfg(any(
143+
feature = "mailersend",
144+
feature = "terminal",
145+
feature = "smtp",
146+
feature = "memory",
147+
feature = "document-features"
148+
))]
119149
impl EmailClient {
120150
/// Unwrap the `EmailClient` enum variant and convert it into a `Box<dyn EmailTrait + Send>`.
121151
///

tests/clients.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
#[cfg(any(feature = "mailersend", feature = "terminal", feature = "smtp", feature = "memory", feature = "document-features"))]
1+
#[cfg(any(
2+
feature = "mailersend",
3+
feature = "terminal",
4+
feature = "smtp",
5+
feature = "memory",
6+
feature = "document-features"
7+
))]
28
use email_clients::clients::get_email_client;
39
#[cfg(feature = "memory")]
410
use email_clients::clients::memory::MemoryConfig;
511
#[cfg(feature = "smtp")]
612
use email_clients::clients::smtp::SmtpConfig;
7-
#[cfg(any(feature = "mailersend", feature = "terminal", feature = "smtp", feature = "memory", feature = "document-features"))]
13+
#[cfg(any(
14+
feature = "mailersend",
15+
feature = "terminal",
16+
feature = "smtp",
17+
feature = "memory",
18+
feature = "document-features"
19+
))]
820
use email_clients::configuration::EmailConfiguration;
921

1022
#[cfg(feature = "terminal")]

0 commit comments

Comments
 (0)