@@ -9,27 +9,27 @@ pub(crate) trait StyleEditionDefault {
9
9
/// macro to help implement `StyleEditionDefault` for config options
10
10
#[ macro_export]
11
11
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 {
14
14
type ConfigType = $config_ty;
15
15
16
- fn style_edition_default( _: crate :: config:: StyleEdition ) -> Self :: ConfigType {
16
+ fn style_edition_default( _: $ crate:: config:: StyleEdition ) -> Self :: ConfigType {
17
17
$default
18
18
}
19
19
}
20
20
} ;
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 {
23
23
type ConfigType = $config_ty;
24
24
25
25
fn style_edition_default(
26
- style_edition: crate :: config:: StyleEdition ,
26
+ style_edition: $ crate:: config:: StyleEdition ,
27
27
) -> Self :: ConfigType {
28
28
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,
33
33
}
34
34
}
35
35
}
@@ -44,7 +44,7 @@ mod test {
44
44
#[ test]
45
45
fn test_impl_default_style_edition_struct_for_all_editions ( ) {
46
46
struct Unit ;
47
- style_edition_default ! ( Unit , usize , 100 ) ;
47
+ style_edition_default ! ( Unit , usize , _ => 100 ) ;
48
48
49
49
// regardless of the style edition used the value will always return 100
50
50
assert_eq ! ( Unit :: style_edition_default( StyleEdition :: Edition2015 ) , 100 ) ;
@@ -56,7 +56,7 @@ mod test {
56
56
#[ test]
57
57
fn test_impl_default_style_edition_for_old_and_new_editions ( ) {
58
58
struct Unit ;
59
- style_edition_default ! ( Unit , usize , 100 , 50 ) ;
59
+ style_edition_default ! ( Unit , usize , Edition2024 => 50 , _ => 100 ) ;
60
60
61
61
// style edition 2015-2021 are all the same
62
62
assert_eq ! ( Unit :: style_edition_default( StyleEdition :: Edition2015 ) , 100 ) ;
0 commit comments