@@ -151,24 +151,24 @@ impl TypeEntry {
151151 } ) => match tag_type {
152152 EnumTagType :: External => {
153153 validate_default_for_external_enum ( type_space, variants, default)
154- . ok_or_else ( || Error :: invalid_value ( ) )
154+ . ok_or_else ( Error :: invalid_value)
155155 }
156156 EnumTagType :: Internal { tag } => {
157157 validate_default_for_internal_enum ( type_space, variants, default, tag)
158- . ok_or_else ( || Error :: invalid_value ( ) )
158+ . ok_or_else ( Error :: invalid_value)
159159 }
160160 EnumTagType :: Adjacent { tag, content } => {
161161 validate_default_for_adjacent_enum ( type_space, variants, default, tag, content)
162- . ok_or_else ( || Error :: invalid_value ( ) )
162+ . ok_or_else ( Error :: invalid_value)
163163 }
164164 EnumTagType :: Untagged => {
165165 validate_default_for_untagged_enum ( type_space, variants, default)
166- . ok_or_else ( || Error :: invalid_value ( ) )
166+ . ok_or_else ( Error :: invalid_value)
167167 }
168168 } ,
169169 TypeEntryDetails :: Struct ( TypeEntryStruct { properties, .. } ) => {
170170 validate_default_struct_props ( properties, type_space, default)
171- . ok_or_else ( || Error :: invalid_value ( ) )
171+ . ok_or_else ( Error :: invalid_value)
172172 }
173173
174174 TypeEntryDetails :: Newtype ( TypeEntryNewtype { type_id, .. } ) => {
@@ -242,8 +242,9 @@ impl TypeEntry {
242242 Err ( Error :: invalid_value ( ) )
243243 }
244244 }
245- TypeEntryDetails :: Tuple ( ids) => validate_default_tuple ( ids, type_space, default)
246- . ok_or_else ( || Error :: invalid_value ( ) ) ,
245+ TypeEntryDetails :: Tuple ( ids) => {
246+ validate_default_tuple ( ids, type_space, default) . ok_or_else ( Error :: invalid_value)
247+ }
247248
248249 TypeEntryDetails :: Array ( type_id, length) => {
249250 let Some ( arr) = default. as_array ( ) else {
@@ -648,10 +649,9 @@ mod tests {
648649 let ( type_space, type_id) = get_type :: < Option < u32 > > ( ) ;
649650 let type_entry = type_space. id_to_entry . get ( & type_id) . unwrap ( ) ;
650651
651- assert ! ( matches!(
652- type_entry. validate_value( & type_space, & json!( "forty-two" ) ) ,
653- Err ( _)
654- ) ) ;
652+ assert ! ( type_entry
653+ . validate_value( & type_space, & json!( "forty-two" ) )
654+ . is_err( ) ) ;
655655 assert ! ( matches!(
656656 type_entry. validate_value( & type_space, & json!( null) ) ,
657657 Ok ( DefaultKind :: Intrinsic )
@@ -671,10 +671,9 @@ mod tests {
671671 extra_derives : Default :: default ( ) ,
672672 } ;
673673
674- assert ! ( matches!(
675- type_entry. validate_value( & type_space, & json!( "forty-two" ) ) ,
676- Err ( _)
677- ) ) ;
674+ assert ! ( type_entry
675+ . validate_value( & type_space, & json!( "forty-two" ) )
676+ . is_err( ) ) ;
678677 assert ! ( matches!(
679678 type_entry. validate_value( & type_space, & json!( null) ) ,
680679 Ok ( DefaultKind :: Intrinsic )
@@ -690,10 +689,9 @@ mod tests {
690689 let ( type_space, type_id) = get_type :: < Vec < u32 > > ( ) ;
691690 let type_entry = type_space. id_to_entry . get ( & type_id) . unwrap ( ) ;
692691
693- assert ! ( matches!(
694- type_entry. validate_value( & type_space, & json!( [ null] ) ) ,
695- Err ( _) ,
696- ) ) ;
692+ assert ! ( type_entry
693+ . validate_value( & type_space, & json!( [ null] ) )
694+ . is_err( ) ) ;
697695 assert ! ( matches!(
698696 type_entry. validate_value( & type_space, & json!( [ ] ) ) ,
699697 Ok ( DefaultKind :: Intrinsic ) ,
@@ -709,10 +707,7 @@ mod tests {
709707 let ( type_space, type_id) = get_type :: < HashMap < String , u32 > > ( ) ;
710708 let type_entry = type_space. id_to_entry . get ( & type_id) . unwrap ( ) ;
711709
712- assert ! ( matches!(
713- type_entry. validate_value( & type_space, & json!( [ ] ) ) ,
714- Err ( _) ,
715- ) ) ;
710+ assert ! ( type_entry. validate_value( & type_space, & json!( [ ] ) ) . is_err( ) ) ;
716711 assert ! ( matches!(
717712 type_entry. validate_value( & type_space, & json!( { } ) ) ,
718713 Ok ( DefaultKind :: Intrinsic ) ,
@@ -728,10 +723,9 @@ mod tests {
728723 let ( type_space, type_id) = get_type :: < ( u32 , u32 , String ) > ( ) ;
729724 let type_entry = type_space. id_to_entry . get ( & type_id) . unwrap ( ) ;
730725
731- assert ! ( matches!(
732- type_entry. validate_value( & type_space, & json!( [ 1 , 2 , "three" , 4 ] ) ) ,
733- Err ( _) ,
734- ) ) ;
726+ assert ! ( type_entry
727+ . validate_value( & type_space, & json!( [ 1 , 2 , "three" , 4 ] ) )
728+ . is_err( ) ) ;
735729 assert ! ( matches!(
736730 type_entry. validate_value( & type_space, & json!( [ 1 , 2 , "three" ] ) ) ,
737731 Ok ( DefaultKind :: Specific ) ,
@@ -769,10 +763,9 @@ mod tests {
769763 let ( type_space, type_id) = get_type :: < u32 > ( ) ;
770764 let type_entry = type_space. id_to_entry . get ( & type_id) . unwrap ( ) ;
771765
772- assert ! ( matches!(
773- type_entry. validate_value( & type_space, & json!( true ) ) ,
774- Err ( _) ,
775- ) ) ;
766+ assert ! ( type_entry
767+ . validate_value( & type_space, & json!( true ) )
768+ . is_err( ) ) ;
776769 assert ! ( matches!(
777770 type_entry. validate_value( & type_space, & json!( 0 ) ) ,
778771 Ok ( DefaultKind :: Intrinsic ) ,
@@ -822,8 +815,8 @@ mod tests {
822815 ) ,
823816 Ok ( DefaultKind :: Specific ) ,
824817 ) ) ;
825- assert ! ( matches! (
826- type_entry . validate_value(
818+ assert ! ( type_entry
819+ . validate_value(
827820 & type_space,
828821 & json!(
829822 {
@@ -832,11 +825,10 @@ mod tests {
832825 "d" : 7
833826 }
834827 )
835- ) ,
836- Err ( _) ,
837- ) ) ;
838- assert ! ( matches!(
839- type_entry. validate_value(
828+ )
829+ . is_err( ) ) ;
830+ assert ! ( type_entry
831+ . validate_value(
840832 & type_space,
841833 & json!(
842834 {
@@ -845,9 +837,8 @@ mod tests {
845837 "d" : { }
846838 }
847839 )
848- ) ,
849- Err ( _) ,
850- ) ) ;
840+ )
841+ . is_err( ) ) ;
851842 }
852843
853844 #[ test]
@@ -885,14 +876,10 @@ mod tests {
885876 ) ,
886877 Ok ( DefaultKind :: Specific ) ,
887878 ) ) ;
888- assert ! ( matches!(
889- type_entry. validate_value( & type_space, & json!( { "A" : null } ) ) ,
890- Err ( _) ,
891- ) ) ;
892- assert ! ( matches!(
893- type_entry. validate_value( & type_space, & json!( "B" ) ) ,
894- Err ( _) ,
895- ) ) ;
879+ assert ! ( type_entry
880+ . validate_value( & type_space, & json!( { "A" : null } ) )
881+ . is_err( ) ) ;
882+ assert ! ( type_entry. validate_value( & type_space, & json!( "B" ) ) . is_err( ) ) ;
896883 }
897884
898885 #[ test]
@@ -928,25 +915,23 @@ mod tests {
928915 ) ,
929916 Ok ( DefaultKind :: Specific ) ,
930917 ) ) ;
931- assert ! ( matches! (
932- type_entry . validate_value(
918+ assert ! ( type_entry
919+ . validate_value(
933920 & type_space,
934921 & json!( {
935922 "not-tag" : "A"
936923 } )
937- ) ,
938- Err ( _) ,
939- ) ) ;
940- assert ! ( matches!(
941- type_entry. validate_value(
924+ )
925+ . is_err( ) ) ;
926+ assert ! ( type_entry
927+ . validate_value(
942928 & type_space,
943929 & json!( {
944930 "tag" : "B" ,
945931 "cc" : "where's D?"
946932 } )
947- ) ,
948- Err ( _) ,
949- ) ) ;
933+ )
934+ . is_err( ) ) ;
950935 }
951936
952937 #[ test]
@@ -992,20 +977,16 @@ mod tests {
992977 ) ,
993978 Ok ( DefaultKind :: Specific ) ,
994979 ) ) ;
995- assert ! ( matches!(
996- type_entry. validate_value( & type_space, & json!( "A" ) ) ,
997- Err ( _) ,
998- ) ) ;
999- assert ! ( matches!(
1000- type_entry. validate_value(
980+ assert ! ( type_entry. validate_value( & type_space, & json!( "A" ) ) . is_err( ) ) ;
981+ assert ! ( type_entry
982+ . validate_value(
1001983 & type_space,
1002984 & json!( {
1003985 "tag" : "A" ,
1004986 "content" : null,
1005987 } )
1006- ) ,
1007- Err ( _) ,
1008- ) ) ;
988+ )
989+ . is_err( ) ) ;
1009990 }
1010991 #[ test]
1011992 fn test_enum_untagged ( ) {
@@ -1033,9 +1014,6 @@ mod tests {
10331014 type_entry. validate_value( & type_space, & json!( { "cc" : "xx" , "dd" : "yy" } ) ) ,
10341015 Ok ( DefaultKind :: Specific ) ,
10351016 ) ) ;
1036- assert ! ( matches!(
1037- type_entry. validate_value( & type_space, & json!( { } ) ) ,
1038- Err ( _) ,
1039- ) ) ;
1017+ assert ! ( type_entry. validate_value( & type_space, & json!( { } ) ) . is_err( ) ) ;
10401018 }
10411019}
0 commit comments