Skip to content

Commit 10ce986

Browse files
committed
address review comments
* replaced `crate::*` with `$crate::*` * updated the `style_edition_default!` to use a match like syntax
1 parent 13ad68a commit 10ce986

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/config/style_edition.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ pub(crate) trait StyleEditionDefault {
99
/// macro to help implement `StyleEditionDefault` for config options
1010
#[macro_export]
1111
macro_rules! style_edition_default {
12-
($ty:ident, $config_ty:ty, $default:expr) => {
13-
impl crate::config::style_edition::StyleEditionDefault for $ty {
12+
($ty:ident, $config_ty:ty, _ => $default:expr) => {
13+
impl $crate::config::style_edition::StyleEditionDefault for $ty {
1414
type ConfigType = $config_ty;
1515

16-
fn style_edition_default(_: crate::config::StyleEdition) -> Self::ConfigType {
16+
fn style_edition_default(_: $crate::config::StyleEdition) -> Self::ConfigType {
1717
$default
1818
}
1919
}
2020
};
21-
($ty:ident, $config_ty:ty, $default_2015:expr, $default_2024:expr) => {
22-
impl crate::config::style_edition::StyleEditionDefault for $ty {
21+
($ty:ident, $config_ty:ty, Edition2024 => $default_2024:expr, _ => $default_2015:expr) => {
22+
impl $crate::config::style_edition::StyleEditionDefault for $ty {
2323
type ConfigType = $config_ty;
2424

2525
fn style_edition_default(
26-
style_edition: crate::config::StyleEdition,
26+
style_edition: $crate::config::StyleEdition,
2727
) -> Self::ConfigType {
2828
match style_edition {
29-
crate::config::StyleEdition::Edition2015
30-
| crate::config::StyleEdition::Edition2018
31-
| crate::config::StyleEdition::Edition2021 => $default_2015,
32-
crate::config::StyleEdition::Edition2024 => $default_2024,
29+
$crate::config::StyleEdition::Edition2015
30+
| $crate::config::StyleEdition::Edition2018
31+
| $crate::config::StyleEdition::Edition2021 => $default_2015,
32+
$crate::config::StyleEdition::Edition2024 => $default_2024,
3333
}
3434
}
3535
}
@@ -44,7 +44,7 @@ mod test {
4444
#[test]
4545
fn test_impl_default_style_edition_struct_for_all_editions() {
4646
struct Unit;
47-
style_edition_default!(Unit, usize, 100);
47+
style_edition_default!(Unit, usize, _ => 100);
4848

4949
// regardless of the style edition used the value will always return 100
5050
assert_eq!(Unit::style_edition_default(StyleEdition::Edition2015), 100);
@@ -56,7 +56,7 @@ mod test {
5656
#[test]
5757
fn test_impl_default_style_edition_for_old_and_new_editions() {
5858
struct Unit;
59-
style_edition_default!(Unit, usize, 100, 50);
59+
style_edition_default!(Unit, usize, Edition2024 => 50, _ => 100);
6060

6161
// style edition 2015-2021 are all the same
6262
assert_eq!(Unit::style_edition_default(StyleEdition::Edition2015), 100);

0 commit comments

Comments
 (0)