`defmt_macros`: Simplify `fn necessary_features_for_level(...)`
@@ -209,53 +209,33 @@ pub fn timestamp(ts: TokenStream) -> TokenStream {
}
}
-// returns a list of features of which one has to be enabled for `level` to be active
+/// Returns a list of features of which one has to be enabled for `level` to be active
+///
+/// * `debug_assertions == true` means that dev profile is enabled
+/// * `"defmt-default"` is enabled for dev & release profile so debug_assertions does not matter
fn necessary_features_for_level(level: Level, debug_assertions: bool) -> &'static [&'static str] {
match level {
- Level::Trace => {
- if debug_assertions {
- // dev profile
- &["defmt-trace", "defmt-default"]
- } else {
- &["defmt-trace"]
- }
- }
- Level::Debug => {
- if debug_assertions {
- // dev profile
- &["defmt-debug", "defmt-trace", "defmt-default"]
- } else {
- &["defmt-debug", "defmt-trace"]
- }
- }
- Level::Info => {
- // defmt-default is enabled for dev & release profile so debug_assertions
- // does not matter
- &["defmt-info", "defmt-debug", "defmt-trace", "defmt-default"]
- }
- Level::Warn => {
- // defmt-default is enabled for dev & release profile so debug_assertions
- // does not matter
- &[
+ Level::Trace if debug_assertions => &["defmt-trace", "defmt-default"],
+ Level::Debug if debug_assertions => &["defmt-debug", "defmt-trace", "defmt-default"],
+
+ Level::Trace => &["defmt-trace"],
+ Level::Debug => &["defmt-debug", "defmt-trace"],
+ Level::Info => &["defmt-info", "defmt-debug", "defmt-trace", "defmt-default"],
+ Level::Warn => &[
"defmt-warn",
"defmt-info",
"defmt-debug",
"defmt-trace",
"defmt-default",
- ]
- }
- Level::Error => {
- // defmt-default is enabled for dev & release profile so debug_assertions
- // does not matter
- &[
+ ],
+ Level::Error => &[
"defmt-error",
"defmt-warn",
"defmt-info",
"defmt-debug",
"defmt-trace",
"defmt-default",
- ]
- }
+ ],
}
}
