Skip to content

Commit 69b8331

Browse files
committed
use standard macro braces
1 parent 93df012 commit 69b8331

File tree

1 file changed

+55
-55
lines changed

1 file changed

+55
-55
lines changed

capnpc/src/codegen.rs

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,24 +1408,24 @@ fn generate_pipeline_getter(
14081408
let typ = reg_field.get_type()?;
14091409
match typ.which()? {
14101410
type_::Struct(_) | type_::AnyPointer(_) => {
1411-
Ok(Branch(vec!(
1411+
Ok(Branch(vec![
14121412
Line(format!("pub fn get_{}(&self) -> {} {{",
14131413
camel_to_snake_case(name),
14141414
typ.type_string(gen, Leaf::Pipeline)?)),
14151415
Indent(Box::new(Line(
14161416
format!("::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field({}))",
14171417
reg_field.get_offset())))),
1418-
Line("}".to_string()))))
1418+
Line("}".to_string())]))
14191419
}
14201420
type_::Interface(_) => {
1421-
Ok(Branch(vec!(
1421+
Ok(Branch(vec![
14221422
Line(format!("pub fn get_{}(&self) -> {} {{",
14231423
camel_to_snake_case(name),
14241424
typ.type_string(gen, Leaf::Client)?)),
14251425
Indent(Box::new(Line(
14261426
format!("::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field({}).as_cap())",
14271427
reg_field.get_offset())))),
1428-
Line("}".to_string()))))
1428+
Line("}".to_string())]))
14291429
}
14301430
_ => {
14311431
Ok(Branch(Vec::new()))
@@ -1674,12 +1674,12 @@ fn generate_node(
16741674
}
16751675

16761676
let builder_struct_size =
1677-
Branch(vec!(
1677+
Branch(vec![
16781678
Line(format!("impl <'a,{0}> ::capnp::traits::HasStructSize for Builder<'a,{0}> {1} {{",
16791679
params.params, params.where_clause)),
16801680
Indent(Box::new(Line(
16811681
format!("const STRUCT_SIZE: ::capnp::private::layout::StructSize = ::capnp::private::layout::StructSize {{ data: {}, pointers: {} }};", data_size as usize, pointer_size as usize)))),
1682-
Line("}".to_string())));
1682+
Line("}".to_string())]);
16831683

16841684
private_mod_interior.push(Line(format!(
16851685
"pub const TYPE_ID: u64 = {};",
@@ -1691,28 +1691,28 @@ fn generate_node(
16911691
Line(format!("impl <'a,{0}> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,{0}> {1} {{", params.params, params.where_clause)),
16921692
Indent(
16931693
Box::new(
1694-
Branch(vec!(
1694+
Branch(vec![
16951695
Line("fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self {".to_string()),
16961696
Indent(Box::new(Line("builder.init_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE).into()".to_string()))),
16971697
Line("}".to_string()),
16981698
Line("fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {".to_string()),
16991699
Indent(Box::new(Line("::core::result::Result::Ok(builder.get_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE, default)?.into())".to_string()))),
1700-
Line("}".to_string()))))),
1700+
Line("}".to_string())]))),
17011701
Line("}".to_string()),
17021702
BlankLine]);
17031703

17041704
let accessors = vec![
17051705
Branch(preamble),
17061706
(if !is_generic {
1707-
Branch(vec!(
1707+
Branch(vec![
17081708
Line("#[derive(Copy, Clone)]".into()),
17091709
Line("pub struct Owned(());".to_string()),
17101710
Line("impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }".to_string()),
17111711
Line("impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }".to_string()),
17121712
Line("impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }".to_string())
1713-
))
1713+
])
17141714
} else {
1715-
Branch(vec!(
1715+
Branch(vec![
17161716
Line("#[derive(Copy, Clone)]".into()),
17171717
Line(format!("pub struct Owned<{}> {{", params.params)),
17181718
Indent(Box::new(Line(params.phantom_data_type.clone()))),
@@ -1723,62 +1723,62 @@ fn generate_node(
17231723
params.params, params.where_clause)),
17241724
Line(format!("impl <{0}> ::capnp::traits::Pipelined for Owned<{0}> {1} {{ type Pipeline = Pipeline{2}; }}",
17251725
params.params, params.where_clause, bracketed_params)),
1726-
))
1726+
])
17271727
}),
17281728
BlankLine,
17291729
Line("#[derive(Clone, Copy)]".to_string()),
17301730
(if !is_generic {
17311731
Line("pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }".to_string())
17321732
} else {
1733-
Branch(vec!(
1733+
Branch(vec![
17341734
Line(format!("pub struct Reader<'a,{}> {} {{", params.params, params.where_clause)),
1735-
Indent(Box::new(Branch(vec!(
1735+
Indent(Box::new(Branch(vec![
17361736
Line("reader: ::capnp::private::layout::StructReader<'a>,".to_string()),
17371737
Line(params.phantom_data_type.clone()),
1738-
)))),
1738+
]))),
17391739
Line("}".to_string())
1740-
))
1740+
])
17411741
}),
17421742
BlankLine,
1743-
Branch(vec!(
1743+
Branch(vec![
17441744
Line(format!("impl <'a,{0}> ::capnp::traits::HasTypeId for Reader<'a,{0}> {1} {{",
17451745
params.params, params.where_clause)),
1746-
Indent(Box::new(Branch(vec!(Line("const TYPE_ID: u64 = _private::TYPE_ID;".to_string()))))),
1747-
Line("}".to_string()))),
1746+
Indent(Box::new(Branch(vec![Line("const TYPE_ID: u64 = _private::TYPE_ID;".to_string())]))),
1747+
Line("}".to_string())]),
17481748
Line(format!("impl <'a,{0}> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,{0}> {1} {{",
17491749
params.params, params.where_clause)),
17501750
Indent(
1751-
Box::new(Branch(vec!(
1751+
Box::new(Branch(vec![
17521752
Line("fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self {".to_string()),
17531753
Indent(Box::new(Line(format!("Self {{ reader, {} }}", params.phantom_data_value)))),
1754-
Line("}".to_string()))))),
1754+
Line("}".to_string())]))),
17551755
Line("}".to_string()),
17561756
BlankLine,
17571757
Line(format!("impl <'a,{0}> ::capnp::traits::FromPointerReader<'a> for Reader<'a,{0}> {1} {{",
17581758
params.params, params.where_clause)),
17591759
Indent(
1760-
Box::new(Branch(vec!(
1760+
Box::new(Branch(vec![
17611761
Line("fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {".to_string()),
17621762
Indent(Box::new(Line("::core::result::Result::Ok(reader.get_struct(default)?.into())".to_string()))),
1763-
Line("}".to_string()))))),
1763+
Line("}".to_string())]))),
17641764
Line("}".to_string()),
17651765
BlankLine,
17661766
Line(format!("impl <'a,{0}> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,{0}> {1} {{",
17671767
params.params, params.where_clause)),
17681768
Indent(
1769-
Box::new(Branch(vec!(
1769+
Box::new(Branch(vec![
17701770
Line("fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {".to_string()),
17711771
Indent(Box::new(Line("self.reader".to_string()))),
1772-
Line("}".to_string()))))),
1772+
Line("}".to_string())]))),
17731773
Line("}".to_string()),
17741774
BlankLine,
17751775
Line(format!("impl <'a,{0}> ::capnp::traits::Imbue<'a> for Reader<'a,{0}> {1} {{",
17761776
params.params, params.where_clause)),
17771777
Indent(
1778-
Box::new(Branch(vec!(
1778+
Box::new(Branch(vec![
17791779
Line("fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {".to_string()),
17801780
Indent(Box::new(Line("self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))".to_string()))),
1781-
Line("}".to_string()))))),
1781+
Line("}".to_string())]))),
17821782
Line("}".to_string()),
17831783
BlankLine,
17841784
Line(format!("impl <'a,{0}> Reader<'a,{0}> {1} {{", params.params, params.where_clause)),
@@ -1797,40 +1797,40 @@ fn generate_node(
17971797
(if !is_generic {
17981798
Line("pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }".to_string())
17991799
} else {
1800-
Branch(vec!(
1800+
Branch(vec![
18011801
Line(format!("pub struct Builder<'a,{}> {} {{",
18021802
params.params, params.where_clause)),
1803-
Indent(Box::new(Branch(vec!(
1803+
Indent(Box::new(Branch(vec![
18041804
Line("builder: ::capnp::private::layout::StructBuilder<'a>,".to_string()),
18051805
Line(params.phantom_data_type.clone()),
1806-
)))),
1806+
]))),
18071807
Line("}".to_string())
1808-
))
1808+
])
18091809
}),
18101810
builder_struct_size,
1811-
Branch(vec!(
1811+
Branch(vec![
18121812
Line(format!("impl <'a,{0}> ::capnp::traits::HasTypeId for Builder<'a,{0}> {1} {{",
18131813
params.params, params.where_clause)),
1814-
Indent(Box::new(Branch(vec!(
1815-
Line("const TYPE_ID: u64 = _private::TYPE_ID;".to_string()))))),
1816-
Line("}".to_string()))),
1814+
Indent(Box::new(Branch(vec![
1815+
Line("const TYPE_ID: u64 = _private::TYPE_ID;".to_string())]))),
1816+
Line("}".to_string())]),
18171817
Line(format!(
18181818
"impl <'a,{0}> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,{0}> {1} {{",
18191819
params.params, params.where_clause)),
18201820
Indent(
1821-
Box::new(Branch(vec!(
1821+
Box::new(Branch(vec![
18221822
Line("fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self {".to_string()),
18231823
Indent(Box::new(Line(format!("Self {{ builder, {} }}", params.phantom_data_value)))),
1824-
Line("}".to_string()))))),
1824+
Line("}".to_string())]))),
18251825
Line("}".to_string()),
18261826
BlankLine,
18271827
Line(format!("impl <'a,{0}> ::capnp::traits::ImbueMut<'a> for Builder<'a,{0}> {1} {{",
18281828
params.params, params.where_clause)),
18291829
Indent(
1830-
Box::new(Branch(vec!(
1830+
Box::new(Branch(vec![
18311831
Line("fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {".to_string()),
18321832
Indent(Box::new(Line("self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))".to_string()))),
1833-
Line("}".to_string()))))),
1833+
Line("}".to_string())]))),
18341834
Line("}".to_string()),
18351835
BlankLine,
18361836

@@ -1876,10 +1876,10 @@ fn generate_node(
18761876
}),
18771877
Line(format!("impl{bracketed_params} ::capnp::capability::FromTypelessPipeline for Pipeline{bracketed_params} {{")),
18781878
Indent(
1879-
Box::new(Branch(vec!(
1879+
Box::new(Branch(vec![
18801880
Line("fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self {".to_string()),
18811881
Indent(Box::new(Line(format!("Self {{ _typeless: typeless, {} }}", params.phantom_data_value)))),
1882-
Line("}".to_string()))))),
1882+
Line("}".to_string())]))),
18831883
Line("}".to_string()),
18841884
Line(format!("impl{0} Pipeline{0} {1} {{", bracketed_params,
18851885
params.pipeline_where_clause)),
@@ -2139,7 +2139,7 @@ fn generate_node(
21392139
}
21402140
mod_interior.push(Line("}".to_string()));
21412141
mod_interior.push(
2142-
Branch(vec!(
2142+
Branch(vec![
21432143
Line(format!("impl {bracketed_params} ::capnp::capability::FromClientHook for Client{bracketed_params} {{")),
21442144
Indent(Box::new(Line("fn new(hook: Box<dyn (::capnp::private::capability::ClientHook)>) -> Self {".to_string()))),
21452145
Indent(Box::new(Indent(Box::new(Line(format!("Self {{ client: ::capnp::capability::Client::new(hook), {} }}", params.phantom_data_value)))))),
@@ -2150,16 +2150,16 @@ fn generate_node(
21502150
Indent(Box::new(Line("fn as_client_hook(&self) -> &dyn (::capnp::private::capability::ClientHook) {".to_string()))),
21512151
Indent(Box::new(Indent(Box::new(Line("&*self.client.hook".to_string()))))),
21522152
Indent(Box::new(Line("}".to_string()))),
2153-
Line("}".to_string()))));
2153+
Line("}".to_string())]));
21542154

21552155
mod_interior.push(if !is_generic {
2156-
Branch(vec!(
2156+
Branch(vec![
21572157
Line("#[derive(Copy, Clone)]".into()),
21582158
Line("pub struct Owned(());".to_string()),
21592159
Line("impl ::capnp::traits::Owned for Owned { type Reader<'a> = Client; type Builder<'a> = Client; }".to_string()),
2160-
Line("impl ::capnp::traits::Pipelined for Owned { type Pipeline = Client; }".to_string())))
2160+
Line("impl ::capnp::traits::Pipelined for Owned { type Pipeline = Client; }".to_string())])
21612161
} else {
2162-
Branch(vec!(
2162+
Branch(vec![
21632163
Line("#[derive(Copy, Clone)]".into()),
21642164
Line(format!("pub struct Owned<{}> {} {{", params.params, params.where_clause)),
21652165
Indent(Box::new(Line(params.phantom_data_type.clone()))),
@@ -2169,18 +2169,18 @@ fn generate_node(
21692169
params.params, params.where_clause)),
21702170
Line(format!(
21712171
"impl <{0}> ::capnp::traits::Pipelined for Owned <{0}> {1} {{ type Pipeline = Client{2}; }}",
2172-
params.params, params.where_clause, bracketed_params))))
2172+
params.params, params.where_clause, bracketed_params))])
21732173
});
21742174

2175-
mod_interior.push(Branch(vec!(
2175+
mod_interior.push(Branch(vec![
21762176
Line(format!("impl <'a,{0}> ::capnp::traits::FromPointerReader<'a> for Client<{0}> {1} {{",
21772177
params.params, params.where_clause)),
21782178
Indent(
21792179
Box::new(Branch(vec![
21802180
Line("fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, _default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {".to_string()),
21812181
Indent(Box::new(Line("::core::result::Result::Ok(::capnp::capability::FromClientHook::new(reader.get_capability()?))".to_string()))),
21822182
Line("}".to_string())]))),
2183-
Line("}".to_string()))));
2183+
Line("}".to_string())]));
21842184

21852185
mod_interior.push(Branch(vec![
21862186
Line(format!("impl <'a,{0}> ::capnp::traits::FromPointerBuilder<'a> for Client<{0}> {1} {{",
@@ -2223,12 +2223,12 @@ fn generate_node(
22232223
]));
22242224

22252225
mod_interior.push(
2226-
Branch(vec!(
2226+
Branch(vec![
22272227
Line(format!("impl {bracketed_params} Clone for Client{bracketed_params} {{")),
22282228
Indent(Box::new(Line("fn clone(&self) -> Self {".to_string()))),
22292229
Indent(Box::new(Indent(Box::new(Line(format!("Self {{ client: ::capnp::capability::Client::new(self.client.hook.add_ref()), {} }}", params.phantom_data_value)))))),
22302230
Indent(Box::new(Line("}".to_string()))),
2231-
Line("}".to_string()))));
2231+
Line("}".to_string())]));
22322232

22332233
mod_interior.push(Branch(vec![
22342234
Line(format!(
@@ -2298,7 +2298,7 @@ fn generate_node(
22982298
]));
22992299

23002300
mod_interior.push(
2301-
Branch(vec!(
2301+
Branch(vec![
23022302
(if is_generic {
23032303
Line(format!("impl <{}, _T: Server{}> ::capnp::capability::Server for ServerDispatch<_T,{}> {} {{", params.params, bracketed_params, params.params, params.where_clause))
23042304
} else {
@@ -2312,10 +2312,10 @@ fn generate_node(
23122312
Indent(Box::new(Indent(Box::new(Indent(Box::new(Line("_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented(\"Method not implemented.\".to_string())) }".to_string()))))))),
23132313
Indent(Box::new(Indent(Box::new(Line("}".to_string()))))),
23142314
Indent(Box::new(Line("}".to_string()))),
2315-
Line("}".to_string()))));
2315+
Line("}".to_string())]));
23162316

23172317
mod_interior.push(
2318-
Branch(vec!(
2318+
Branch(vec![
23192319
(if is_generic {
23202320
Line(format!("impl <{}, _T: Server{}> ServerDispatch<_T,{}> {} {{", params.params, bracketed_params, params.params, params.where_clause))
23212321
} else {
@@ -2327,7 +2327,7 @@ fn generate_node(
23272327
Indent(Box::new(Indent(Box::new(Indent(Box::new(Line("_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented(\"Method not implemented.\".to_string())) }".to_string()))))))),
23282328
Indent(Box::new(Indent(Box::new(Line("}".to_string()))))),
23292329
Indent(Box::new(Line("}".to_string()))),
2330-
Line("}".to_string()))));
2330+
Line("}".to_string())]));
23312331

23322332
mod_interior.push(Branch(vec![
23332333
Line("pub mod _private {".to_string()),

0 commit comments

Comments
 (0)