Procházet zdrojové kódy

chore: format code

appflowy před 2 roky
rodič
revize
c1ed5c97ee

+ 2 - 2
shared-lib/flowy-grid-data-model/src/revision/grid_setting_rev.rs

@@ -77,7 +77,7 @@ where
     }
 
     pub fn get_all_objects(&self) -> Vec<Arc<T>> {
-        self.inner.values().map(|map| map.all_objects()).flatten().collect()
+        self.inner.values().flat_map(|map| map.all_objects()).collect()
     }
 
     /// add object to the end of the list
@@ -117,7 +117,7 @@ where
     }
 
     pub fn all_objects(&self) -> Vec<Arc<T>> {
-        self.object_by_field_type.values().cloned().flatten().collect()
+        self.object_by_field_type.values().flatten().cloned().collect()
     }
 }
 

+ 1 - 2
shared-lib/lib-infra/src/code_gen/protobuf_file/ast.rs

@@ -22,8 +22,7 @@ pub fn parse_protobuf_context_from(crate_paths: Vec<String>) -> Vec<ProtobufCrat
             let files = crate_info
                 .proto_input_paths()
                 .iter()
-                .map(|proto_crate_path| parse_files_protobuf(proto_crate_path, &proto_output_path))
-                .flatten()
+                .flat_map(|proto_crate_path| parse_files_protobuf(proto_crate_path, &proto_output_path))
                 .collect::<Vec<ProtoFile>>();
 
             ProtobufCrateContext::from_crate_info(crate_info, files)

+ 4 - 6
shared-lib/lib-infra/src/code_gen/protobuf_file/proto_gen.rs

@@ -52,7 +52,7 @@ impl ProtoGenerator {
 fn write_proto_files(crate_contexts: &[ProtobufCrateContext]) {
     let file_path_content_map = crate_contexts
         .iter()
-        .map(|ctx| {
+        .flat_map(|ctx| {
             ctx.files
                 .iter()
                 .map(|file| {
@@ -66,7 +66,6 @@ fn write_proto_files(crate_contexts: &[ProtobufCrateContext]) {
                 })
                 .collect::<HashMap<String, ProtoFileSymbol>>()
         })
-        .flatten()
         .collect::<HashMap<String, ProtoFileSymbol>>();
 
     for context in crate_contexts {
@@ -152,12 +151,11 @@ impl ProtoCache {
     fn from_crate_contexts(crate_contexts: &[ProtobufCrateContext]) -> Self {
         let proto_files = crate_contexts
             .iter()
-            .map(|crate_info| &crate_info.files)
-            .flatten()
+            .flat_map(|crate_info| &crate_info.files)
             .collect::<Vec<&ProtoFile>>();
 
-        let structs: Vec<String> = proto_files.iter().map(|info| info.structs.clone()).flatten().collect();
-        let enums: Vec<String> = proto_files.iter().map(|info| info.enums.clone()).flatten().collect();
+        let structs: Vec<String> = proto_files.iter().flat_map(|info| info.structs.clone()).collect();
+        let enums: Vec<String> = proto_files.iter().flat_map(|info| info.enums.clone()).collect();
         Self { structs, enums }
     }
 }