File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -54,18 +54,18 @@ impl Mmds {
5454 /// an UnsupportedValueType error if the data contain any value type other than
5555 /// Strings, arrays and dictionaries.
5656 pub fn check_data_valid ( data : & Value ) -> Result < ( ) , Error > {
57- if let Some ( map) = data. as_object ( ) {
58- for key in map. keys ( ) {
59- Mmds :: check_data_valid ( & map[ key] ) ?;
60- }
57+ if data. is_string ( ) {
58+ Ok ( ( ) )
59+ } else if let Some ( map) = data. as_object ( ) {
60+ map. values ( )
61+ . try_for_each ( |value| Mmds :: check_data_valid ( value) )
6162 } else if let Some ( array) = data. as_array ( ) {
62- for obj in array {
63- Mmds :: check_data_valid ( & obj ) ? ;
64- }
65- } else if !data . is_string ( ) {
66- return Err ( Error :: UnsupportedValueType ) ;
63+ array
64+ . iter ( )
65+ . try_for_each ( |value| Mmds :: check_data_valid ( value ) )
66+ } else {
67+ Err ( Error :: UnsupportedValueType )
6768 }
68- Ok ( ( ) )
6969 }
7070
7171 pub fn put_data ( & mut self , data : Value ) -> Result < ( ) , Error > {
You can’t perform that action at this time.
0 commit comments