@@ -1408,24 +1408,24 @@ fn generate_pipeline_getter(
1408
1408
let typ = reg_field. get_type ( ) ?;
1409
1409
match typ. which ( ) ? {
1410
1410
type_:: Struct ( _) | type_:: AnyPointer ( _) => {
1411
- Ok ( Branch ( vec ! (
1411
+ Ok ( Branch ( vec ! [
1412
1412
Line ( format!( "pub fn get_{}(&self) -> {} {{" ,
1413
1413
camel_to_snake_case( name) ,
1414
1414
typ. type_string( gen , Leaf :: Pipeline ) ?) ) ,
1415
1415
Indent ( Box :: new( Line (
1416
1416
format!( "::capnp::capability::FromTypelessPipeline::new(self._typeless.get_pointer_field({}))" ,
1417
1417
reg_field. get_offset( ) ) ) ) ) ,
1418
- Line ( "}" . to_string( ) ) ) ) )
1418
+ Line ( "}" . to_string( ) ) ] ) )
1419
1419
}
1420
1420
type_:: Interface ( _) => {
1421
- Ok ( Branch ( vec ! (
1421
+ Ok ( Branch ( vec ! [
1422
1422
Line ( format!( "pub fn get_{}(&self) -> {} {{" ,
1423
1423
camel_to_snake_case( name) ,
1424
1424
typ. type_string( gen , Leaf :: Client ) ?) ) ,
1425
1425
Indent ( Box :: new( Line (
1426
1426
format!( "::capnp::capability::FromClientHook::new(self._typeless.get_pointer_field({}).as_cap())" ,
1427
1427
reg_field. get_offset( ) ) ) ) ) ,
1428
- Line ( "}" . to_string( ) ) ) ) )
1428
+ Line ( "}" . to_string( ) ) ] ) )
1429
1429
}
1430
1430
_ => {
1431
1431
Ok ( Branch ( Vec :: new ( ) ) )
@@ -1674,12 +1674,12 @@ fn generate_node(
1674
1674
}
1675
1675
1676
1676
let builder_struct_size =
1677
- Branch ( vec ! (
1677
+ Branch ( vec ! [
1678
1678
Line ( format!( "impl <'a,{0}> ::capnp::traits::HasStructSize for Builder<'a,{0}> {1} {{" ,
1679
1679
params. params, params. where_clause) ) ,
1680
1680
Indent ( Box :: new( Line (
1681
1681
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( ) ) ] ) ;
1683
1683
1684
1684
private_mod_interior. push ( Line ( format ! (
1685
1685
"pub const TYPE_ID: u64 = {};" ,
@@ -1691,28 +1691,28 @@ fn generate_node(
1691
1691
Line ( format!( "impl <'a,{0}> ::capnp::traits::FromPointerBuilder<'a> for Builder<'a,{0}> {1} {{" , params. params, params. where_clause) ) ,
1692
1692
Indent (
1693
1693
Box :: new(
1694
- Branch ( vec!(
1694
+ Branch ( vec![
1695
1695
Line ( "fn init_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, _size: u32) -> Self {" . to_string( ) ) ,
1696
1696
Indent ( Box :: new( Line ( "builder.init_struct(<Self as ::capnp::traits::HasStructSize>::STRUCT_SIZE).into()" . to_string( ) ) ) ) ,
1697
1697
Line ( "}" . to_string( ) ) ,
1698
1698
Line ( "fn get_from_pointer(builder: ::capnp::private::layout::PointerBuilder<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {" . to_string( ) ) ,
1699
1699
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( ) ) ] ) ) ) ,
1701
1701
Line ( "}" . to_string( ) ) ,
1702
1702
BlankLine ] ) ;
1703
1703
1704
1704
let accessors = vec ! [
1705
1705
Branch ( preamble) ,
1706
1706
( if !is_generic {
1707
- Branch ( vec!(
1707
+ Branch ( vec![
1708
1708
Line ( "#[derive(Copy, Clone)]" . into( ) ) ,
1709
1709
Line ( "pub struct Owned(());" . to_string( ) ) ,
1710
1710
Line ( "impl ::capnp::traits::Owned for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }" . to_string( ) ) ,
1711
1711
Line ( "impl ::capnp::traits::OwnedStruct for Owned { type Reader<'a> = Reader<'a>; type Builder<'a> = Builder<'a>; }" . to_string( ) ) ,
1712
1712
Line ( "impl ::capnp::traits::Pipelined for Owned { type Pipeline = Pipeline; }" . to_string( ) )
1713
- ) )
1713
+ ] )
1714
1714
} else {
1715
- Branch ( vec!(
1715
+ Branch ( vec![
1716
1716
Line ( "#[derive(Copy, Clone)]" . into( ) ) ,
1717
1717
Line ( format!( "pub struct Owned<{}> {{" , params. params) ) ,
1718
1718
Indent ( Box :: new( Line ( params. phantom_data_type. clone( ) ) ) ) ,
@@ -1723,62 +1723,62 @@ fn generate_node(
1723
1723
params. params, params. where_clause) ) ,
1724
1724
Line ( format!( "impl <{0}> ::capnp::traits::Pipelined for Owned<{0}> {1} {{ type Pipeline = Pipeline{2}; }}" ,
1725
1725
params. params, params. where_clause, bracketed_params) ) ,
1726
- ) )
1726
+ ] )
1727
1727
} ) ,
1728
1728
BlankLine ,
1729
1729
Line ( "#[derive(Clone, Copy)]" . to_string( ) ) ,
1730
1730
( if !is_generic {
1731
1731
Line ( "pub struct Reader<'a> { reader: ::capnp::private::layout::StructReader<'a> }" . to_string( ) )
1732
1732
} else {
1733
- Branch ( vec!(
1733
+ Branch ( vec![
1734
1734
Line ( format!( "pub struct Reader<'a,{}> {} {{" , params. params, params. where_clause) ) ,
1735
- Indent ( Box :: new( Branch ( vec!(
1735
+ Indent ( Box :: new( Branch ( vec![
1736
1736
Line ( "reader: ::capnp::private::layout::StructReader<'a>," . to_string( ) ) ,
1737
1737
Line ( params. phantom_data_type. clone( ) ) ,
1738
- ) ) ) ) ,
1738
+ ] ) ) ) ,
1739
1739
Line ( "}" . to_string( ) )
1740
- ) )
1740
+ ] )
1741
1741
} ) ,
1742
1742
BlankLine ,
1743
- Branch ( vec!(
1743
+ Branch ( vec![
1744
1744
Line ( format!( "impl <'a,{0}> ::capnp::traits::HasTypeId for Reader<'a,{0}> {1} {{" ,
1745
1745
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( ) ) ] ) ,
1748
1748
Line ( format!( "impl <'a,{0}> ::core::convert::From<::capnp::private::layout::StructReader<'a>> for Reader<'a,{0}> {1} {{" ,
1749
1749
params. params, params. where_clause) ) ,
1750
1750
Indent (
1751
- Box :: new( Branch ( vec!(
1751
+ Box :: new( Branch ( vec![
1752
1752
Line ( "fn from(reader: ::capnp::private::layout::StructReader<'a>) -> Self {" . to_string( ) ) ,
1753
1753
Indent ( Box :: new( Line ( format!( "Self {{ reader, {} }}" , params. phantom_data_value) ) ) ) ,
1754
- Line ( "}" . to_string( ) ) ) ) ) ) ,
1754
+ Line ( "}" . to_string( ) ) ] ) ) ) ,
1755
1755
Line ( "}" . to_string( ) ) ,
1756
1756
BlankLine ,
1757
1757
Line ( format!( "impl <'a,{0}> ::capnp::traits::FromPointerReader<'a> for Reader<'a,{0}> {1} {{" ,
1758
1758
params. params, params. where_clause) ) ,
1759
1759
Indent (
1760
- Box :: new( Branch ( vec!(
1760
+ Box :: new( Branch ( vec![
1761
1761
Line ( "fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {" . to_string( ) ) ,
1762
1762
Indent ( Box :: new( Line ( "::core::result::Result::Ok(reader.get_struct(default)?.into())" . to_string( ) ) ) ) ,
1763
- Line ( "}" . to_string( ) ) ) ) ) ) ,
1763
+ Line ( "}" . to_string( ) ) ] ) ) ) ,
1764
1764
Line ( "}" . to_string( ) ) ,
1765
1765
BlankLine ,
1766
1766
Line ( format!( "impl <'a,{0}> ::capnp::traits::IntoInternalStructReader<'a> for Reader<'a,{0}> {1} {{" ,
1767
1767
params. params, params. where_clause) ) ,
1768
1768
Indent (
1769
- Box :: new( Branch ( vec!(
1769
+ Box :: new( Branch ( vec![
1770
1770
Line ( "fn into_internal_struct_reader(self) -> ::capnp::private::layout::StructReader<'a> {" . to_string( ) ) ,
1771
1771
Indent ( Box :: new( Line ( "self.reader" . to_string( ) ) ) ) ,
1772
- Line ( "}" . to_string( ) ) ) ) ) ) ,
1772
+ Line ( "}" . to_string( ) ) ] ) ) ) ,
1773
1773
Line ( "}" . to_string( ) ) ,
1774
1774
BlankLine ,
1775
1775
Line ( format!( "impl <'a,{0}> ::capnp::traits::Imbue<'a> for Reader<'a,{0}> {1} {{" ,
1776
1776
params. params, params. where_clause) ) ,
1777
1777
Indent (
1778
- Box :: new( Branch ( vec!(
1778
+ Box :: new( Branch ( vec![
1779
1779
Line ( "fn imbue(&mut self, cap_table: &'a ::capnp::private::layout::CapTable) {" . to_string( ) ) ,
1780
1780
Indent ( Box :: new( Line ( "self.reader.imbue(::capnp::private::layout::CapTableReader::Plain(cap_table))" . to_string( ) ) ) ) ,
1781
- Line ( "}" . to_string( ) ) ) ) ) ) ,
1781
+ Line ( "}" . to_string( ) ) ] ) ) ) ,
1782
1782
Line ( "}" . to_string( ) ) ,
1783
1783
BlankLine ,
1784
1784
Line ( format!( "impl <'a,{0}> Reader<'a,{0}> {1} {{" , params. params, params. where_clause) ) ,
@@ -1797,40 +1797,40 @@ fn generate_node(
1797
1797
( if !is_generic {
1798
1798
Line ( "pub struct Builder<'a> { builder: ::capnp::private::layout::StructBuilder<'a> }" . to_string( ) )
1799
1799
} else {
1800
- Branch ( vec!(
1800
+ Branch ( vec![
1801
1801
Line ( format!( "pub struct Builder<'a,{}> {} {{" ,
1802
1802
params. params, params. where_clause) ) ,
1803
- Indent ( Box :: new( Branch ( vec!(
1803
+ Indent ( Box :: new( Branch ( vec![
1804
1804
Line ( "builder: ::capnp::private::layout::StructBuilder<'a>," . to_string( ) ) ,
1805
1805
Line ( params. phantom_data_type. clone( ) ) ,
1806
- ) ) ) ) ,
1806
+ ] ) ) ) ,
1807
1807
Line ( "}" . to_string( ) )
1808
- ) )
1808
+ ] )
1809
1809
} ) ,
1810
1810
builder_struct_size,
1811
- Branch ( vec!(
1811
+ Branch ( vec![
1812
1812
Line ( format!( "impl <'a,{0}> ::capnp::traits::HasTypeId for Builder<'a,{0}> {1} {{" ,
1813
1813
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( ) ) ] ) ,
1817
1817
Line ( format!(
1818
1818
"impl <'a,{0}> ::core::convert::From<::capnp::private::layout::StructBuilder<'a>> for Builder<'a,{0}> {1} {{" ,
1819
1819
params. params, params. where_clause) ) ,
1820
1820
Indent (
1821
- Box :: new( Branch ( vec!(
1821
+ Box :: new( Branch ( vec![
1822
1822
Line ( "fn from(builder: ::capnp::private::layout::StructBuilder<'a>) -> Self {" . to_string( ) ) ,
1823
1823
Indent ( Box :: new( Line ( format!( "Self {{ builder, {} }}" , params. phantom_data_value) ) ) ) ,
1824
- Line ( "}" . to_string( ) ) ) ) ) ) ,
1824
+ Line ( "}" . to_string( ) ) ] ) ) ) ,
1825
1825
Line ( "}" . to_string( ) ) ,
1826
1826
BlankLine ,
1827
1827
Line ( format!( "impl <'a,{0}> ::capnp::traits::ImbueMut<'a> for Builder<'a,{0}> {1} {{" ,
1828
1828
params. params, params. where_clause) ) ,
1829
1829
Indent (
1830
- Box :: new( Branch ( vec!(
1830
+ Box :: new( Branch ( vec![
1831
1831
Line ( "fn imbue_mut(&mut self, cap_table: &'a mut ::capnp::private::layout::CapTable) {" . to_string( ) ) ,
1832
1832
Indent ( Box :: new( Line ( "self.builder.imbue(::capnp::private::layout::CapTableBuilder::Plain(cap_table))" . to_string( ) ) ) ) ,
1833
- Line ( "}" . to_string( ) ) ) ) ) ) ,
1833
+ Line ( "}" . to_string( ) ) ] ) ) ) ,
1834
1834
Line ( "}" . to_string( ) ) ,
1835
1835
BlankLine ,
1836
1836
@@ -1880,10 +1880,10 @@ fn generate_node(
1880
1880
} ) ,
1881
1881
Line ( format!( "impl{bracketed_params} ::capnp::capability::FromTypelessPipeline for Pipeline{bracketed_params} {{" ) ) ,
1882
1882
Indent (
1883
- Box :: new( Branch ( vec!(
1883
+ Box :: new( Branch ( vec![
1884
1884
Line ( "fn new(typeless: ::capnp::any_pointer::Pipeline) -> Self {" . to_string( ) ) ,
1885
1885
Indent ( Box :: new( Line ( format!( "Self {{ _typeless: typeless, {} }}" , params. phantom_data_value) ) ) ) ,
1886
- Line ( "}" . to_string( ) ) ) ) ) ) ,
1886
+ Line ( "}" . to_string( ) ) ] ) ) ) ,
1887
1887
Line ( "}" . to_string( ) ) ,
1888
1888
Line ( format!( "impl{0} Pipeline{0} {1} {{" , bracketed_params,
1889
1889
params. pipeline_where_clause) ) ,
@@ -2143,7 +2143,7 @@ fn generate_node(
2143
2143
}
2144
2144
mod_interior. push ( Line ( "}" . to_string ( ) ) ) ;
2145
2145
mod_interior. push (
2146
- Branch ( vec ! (
2146
+ Branch ( vec ! [
2147
2147
Line ( format!( "impl {bracketed_params} ::capnp::capability::FromClientHook for Client{bracketed_params} {{" ) ) ,
2148
2148
Indent ( Box :: new( Line ( "fn new(hook: Box<dyn (::capnp::private::capability::ClientHook)>) -> Self {" . to_string( ) ) ) ) ,
2149
2149
Indent ( Box :: new( Indent ( Box :: new( Line ( format!( "Self {{ client: ::capnp::capability::Client::new(hook), {} }}" , params. phantom_data_value) ) ) ) ) ) ,
@@ -2154,16 +2154,16 @@ fn generate_node(
2154
2154
Indent ( Box :: new( Line ( "fn as_client_hook(&self) -> &dyn (::capnp::private::capability::ClientHook) {" . to_string( ) ) ) ) ,
2155
2155
Indent ( Box :: new( Indent ( Box :: new( Line ( "&*self.client.hook" . to_string( ) ) ) ) ) ) ,
2156
2156
Indent ( Box :: new( Line ( "}" . to_string( ) ) ) ) ,
2157
- Line ( "}" . to_string( ) ) ) ) ) ;
2157
+ Line ( "}" . to_string( ) ) ] ) ) ;
2158
2158
2159
2159
mod_interior. push ( if !is_generic {
2160
- Branch ( vec ! (
2160
+ Branch ( vec ! [
2161
2161
Line ( "#[derive(Copy, Clone)]" . into( ) ) ,
2162
2162
Line ( "pub struct Owned(());" . to_string( ) ) ,
2163
2163
Line ( "impl ::capnp::traits::Owned for Owned { type Reader<'a> = Client; type Builder<'a> = Client; }" . to_string( ) ) ,
2164
- Line ( "impl ::capnp::traits::Pipelined for Owned { type Pipeline = Client; }" . to_string( ) ) ) )
2164
+ Line ( "impl ::capnp::traits::Pipelined for Owned { type Pipeline = Client; }" . to_string( ) ) ] )
2165
2165
} else {
2166
- Branch ( vec ! (
2166
+ Branch ( vec ! [
2167
2167
Line ( "#[derive(Copy, Clone)]" . into( ) ) ,
2168
2168
Line ( format!( "pub struct Owned<{}> {} {{" , params. params, params. where_clause) ) ,
2169
2169
Indent ( Box :: new( Line ( params. phantom_data_type. clone( ) ) ) ) ,
@@ -2173,18 +2173,18 @@ fn generate_node(
2173
2173
params. params, params. where_clause) ) ,
2174
2174
Line ( format!(
2175
2175
"impl <{0}> ::capnp::traits::Pipelined for Owned <{0}> {1} {{ type Pipeline = Client{2}; }}" ,
2176
- params. params, params. where_clause, bracketed_params) ) ) )
2176
+ params. params, params. where_clause, bracketed_params) ) ] )
2177
2177
} ) ;
2178
2178
2179
- mod_interior. push ( Branch ( vec ! (
2179
+ mod_interior. push ( Branch ( vec ! [
2180
2180
Line ( format!( "impl <'a,{0}> ::capnp::traits::FromPointerReader<'a> for Client<{0}> {1} {{" ,
2181
2181
params. params, params. where_clause) ) ,
2182
2182
Indent (
2183
2183
Box :: new( Branch ( vec![
2184
2184
Line ( "fn get_from_pointer(reader: &::capnp::private::layout::PointerReader<'a>, _default: ::core::option::Option<&'a [capnp::Word]>) -> ::capnp::Result<Self> {" . to_string( ) ) ,
2185
2185
Indent ( Box :: new( Line ( "::core::result::Result::Ok(::capnp::capability::FromClientHook::new(reader.get_capability()?))" . to_string( ) ) ) ) ,
2186
2186
Line ( "}" . to_string( ) ) ] ) ) ) ,
2187
- Line ( "}" . to_string( ) ) ) ) ) ;
2187
+ Line ( "}" . to_string( ) ) ] ) ) ;
2188
2188
2189
2189
mod_interior. push ( Branch ( vec ! [
2190
2190
Line ( format!( "impl <'a,{0}> ::capnp::traits::FromPointerBuilder<'a> for Client<{0}> {1} {{" ,
@@ -2227,12 +2227,12 @@ fn generate_node(
2227
2227
] ) ) ;
2228
2228
2229
2229
mod_interior. push (
2230
- Branch ( vec ! (
2230
+ Branch ( vec ! [
2231
2231
Line ( format!( "impl {bracketed_params} Clone for Client{bracketed_params} {{" ) ) ,
2232
2232
Indent ( Box :: new( Line ( "fn clone(&self) -> Self {" . to_string( ) ) ) ) ,
2233
2233
Indent ( Box :: new( Indent ( Box :: new( Line ( format!( "Self {{ client: ::capnp::capability::Client::new(self.client.hook.add_ref()), {} }}" , params. phantom_data_value) ) ) ) ) ) ,
2234
2234
Indent ( Box :: new( Line ( "}" . to_string( ) ) ) ) ,
2235
- Line ( "}" . to_string( ) ) ) ) ) ;
2235
+ Line ( "}" . to_string( ) ) ] ) ) ;
2236
2236
2237
2237
mod_interior. push ( Branch ( vec ! [
2238
2238
Line ( format!(
@@ -2302,7 +2302,7 @@ fn generate_node(
2302
2302
] ) ) ;
2303
2303
2304
2304
mod_interior. push (
2305
- Branch ( vec ! (
2305
+ Branch ( vec ! [
2306
2306
( if is_generic {
2307
2307
Line ( format!( "impl <{}, _T: Server{}> ::capnp::capability::Server for ServerDispatch<_T,{}> {} {{" , params. params, bracketed_params, params. params, params. where_clause) )
2308
2308
} else {
@@ -2316,10 +2316,10 @@ fn generate_node(
2316
2316
Indent ( Box :: new( Indent ( Box :: new( Indent ( Box :: new( Line ( "_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented(\" Method not implemented.\" .to_string())) }" . to_string( ) ) ) ) ) ) ) ) ,
2317
2317
Indent ( Box :: new( Indent ( Box :: new( Line ( "}" . to_string( ) ) ) ) ) ) ,
2318
2318
Indent ( Box :: new( Line ( "}" . to_string( ) ) ) ) ,
2319
- Line ( "}" . to_string( ) ) ) ) ) ;
2319
+ Line ( "}" . to_string( ) ) ] ) ) ;
2320
2320
2321
2321
mod_interior. push (
2322
- Branch ( vec ! (
2322
+ Branch ( vec ! [
2323
2323
( if is_generic {
2324
2324
Line ( format!( "impl <{}, _T: Server{}> ServerDispatch<_T,{}> {} {{" , params. params, bracketed_params, params. params, params. where_clause) )
2325
2325
} else {
@@ -2331,7 +2331,7 @@ fn generate_node(
2331
2331
Indent ( Box :: new( Indent ( Box :: new( Indent ( Box :: new( Line ( "_ => { ::capnp::capability::Promise::err(::capnp::Error::unimplemented(\" Method not implemented.\" .to_string())) }" . to_string( ) ) ) ) ) ) ) ) ,
2332
2332
Indent ( Box :: new( Indent ( Box :: new( Line ( "}" . to_string( ) ) ) ) ) ) ,
2333
2333
Indent ( Box :: new( Line ( "}" . to_string( ) ) ) ) ,
2334
- Line ( "}" . to_string( ) ) ) ) ) ;
2334
+ Line ( "}" . to_string( ) ) ] ) ) ;
2335
2335
2336
2336
mod_interior. push ( Branch ( vec ! [
2337
2337
Line ( "pub mod _private {" . to_string( ) ) ,
0 commit comments