@@ -12,7 +12,7 @@ use std::net::SocketAddr;
1212use std:: str;
1313use uuid:: Uuid ;
1414
15- #[ derive( Debug , Copy , Clone , PartialEq , Eq , PartialOrd , Ord , TryFromPrimitive ) ]
15+ #[ derive( Debug , Copy , Clone , Default , PartialEq , Eq , PartialOrd , Ord , TryFromPrimitive ) ]
1616#[ cfg_attr( feature = "serde" , derive( serde:: Deserialize ) ) ]
1717#[ cfg_attr( feature = "serde" , serde( rename_all = "SCREAMING_SNAKE_CASE" ) ) ]
1818#[ repr( i16 ) ]
@@ -23,6 +23,7 @@ pub enum Consistency {
2323 Three = 0x0003 ,
2424 Quorum = 0x0004 ,
2525 All = 0x0005 ,
26+ #[ default]
2627 LocalQuorum = 0x0006 ,
2728 EachQuorum = 0x0007 ,
2829 LocalOne = 0x000A ,
@@ -46,22 +47,6 @@ pub enum LegacyConsistency {
4647 Serial ( SerialConsistency ) ,
4748}
4849
49- // Although we could `impl Default for Consistency` with an automatic derive,
50- // this would require adding a #[default] annotation on the default variant,
51- // but - unfortunately - that annotation is also recognized by `TryFromPrimitive`
52- // derive macro. If there is a #[default] variant then `TryFromPrimitive`
53- // falls back to it - if not, then it returns an error. This breaks one of the
54- // tests.
55- //
56- // It will be possible to fix this properly after the following issue is closed:
57- // https://github.com/illicitonion/num_enum/issues/75
58- #[ allow( clippy:: derivable_impls) ]
59- impl Default for Consistency {
60- fn default ( ) -> Self {
61- Consistency :: LocalQuorum
62- }
63- }
64-
6550impl std:: fmt:: Display for Consistency {
6651 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
6752 write ! ( f, "{:?}" , self )
0 commit comments