Skip to content

Commit 9d3e031

Browse files
dzfranklindwrensha
authored andcommitted
Rustfmt codegen.rs
1 parent d5595c4 commit 9d3e031

File tree

1 file changed

+45
-21
lines changed

1 file changed

+45
-21
lines changed

capnpc/src/codegen.rs

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -895,38 +895,62 @@ fn zero_fields_of_group(
895895
match typ {
896896
type_::Void(()) => {}
897897
type_::Bool(()) => {
898-
let line = Line(format!("self.builder.set_bool_field({}, false);",
899-
slot.get_offset()));
898+
let line = Line(format!(
899+
"self.builder.set_bool_field({}, false);",
900+
slot.get_offset()
901+
));
900902
// PERF could dedup more efficiently
901-
if !result.contains(&line) { result.push(line) }
903+
if !result.contains(&line) {
904+
result.push(line)
905+
}
902906
}
903-
type_::Int8(()) |
904-
type_::Int16(()) | type_::Int32(()) | type_::Int64(()) |
905-
type_::Uint8(()) | type_::Uint16(()) | type_::Uint32(()) |
906-
type_::Uint64(()) | type_::Float32(()) | type_::Float64(()) => {
907+
type_::Int8(())
908+
| type_::Int16(())
909+
| type_::Int32(())
910+
| type_::Int64(())
911+
| type_::Uint8(())
912+
| type_::Uint16(())
913+
| type_::Uint32(())
914+
| type_::Uint64(())
915+
| type_::Float32(())
916+
| type_::Float64(()) => {
907917
let line = Line(format!(
908918
"self.builder.set_data_field::<{0}>({1}, 0{0});",
909919
slot.get_type()?.type_string(ctx, Leaf::Builder("'a"))?,
910-
slot.get_offset()));
920+
slot.get_offset()
921+
));
911922
// PERF could dedup more efficiently
912-
if !result.contains(&line) { result.push(line) }
923+
if !result.contains(&line) {
924+
result.push(line)
925+
}
913926
}
914927
type_::Enum(_) => {
915-
let line = Line(format!("self.builder.set_data_field::<u16>({}, 0u16);",
916-
slot.get_offset()));
928+
let line = Line(format!(
929+
"self.builder.set_data_field::<u16>({}, 0u16);",
930+
slot.get_offset()
931+
));
917932
// PERF could dedup more efficiently
918-
if !result.contains(&line) { result.push(line) }
933+
if !result.contains(&line) {
934+
result.push(line)
935+
}
919936
}
920-
type_::Struct(_) | type_::List(_) | type_::Text(()) | type_::Data(()) |
921-
type_::AnyPointer(_) |
922-
type_::Interface(_)
923-
=> { // Is this the right thing to do for interfaces?
924-
let line = Line(format!("self.builder.reborrow().get_pointer_field({}).clear();",
925-
slot.get_offset()));
926-
*clear = true;
927-
// PERF could dedup more efficiently
928-
if !result.contains(&line) { result.push(line) }
937+
type_::Struct(_)
938+
| type_::List(_)
939+
| type_::Text(())
940+
| type_::Data(())
941+
| type_::AnyPointer(_)
942+
| type_::Interface(_) => {
943+
// Is this the right thing to do for interfaces?
944+
let line = Line(format!(
945+
"self.builder.reborrow().get_pointer_field({}).clear();",
946+
slot.get_offset()
947+
));
948+
*clear = true;
949+
// PERF could dedup more efficiently
950+
if !result.contains(&line) {
951+
result.push(line)
929952
}
953+
}
930954
}
931955
}
932956
}

0 commit comments

Comments
 (0)