@@ -34,14 +34,14 @@ pub struct TableEndpoint(SocketAddr);
34
34
impl Service < ( ) > for TableEndpoint {
35
35
type Response = multiplex:: MultiplexTransport < Transport , Tagger > ;
36
36
type Error = tokio:: io:: Error ;
37
- type Future = Box < Future < Item = Self :: Response , Error = Self :: Error > + Send > ;
37
+ // have to repeat types because https://github.com/rust-lang/rust/issues/57807
38
+ existential type Future : Future < Item = multiplex:: MultiplexTransport < Transport , Tagger > , Error = tokio:: io:: Error > ;
38
39
39
40
fn poll_ready ( & mut self ) -> Poll < ( ) , Self :: Error > {
40
41
Ok ( Async :: Ready ( ( ) ) )
41
42
}
42
43
43
44
fn call ( & mut self , _: ( ) ) -> Self :: Future {
44
- Box :: new (
45
45
tokio:: net:: TcpStream :: connect ( & self . 0 )
46
46
. map ( |mut s| {
47
47
s. write_all ( & [ CONNECTION_FROM_BASE ] ) . unwrap ( ) ;
@@ -50,8 +50,7 @@ impl Service<()> for TableEndpoint {
50
50
} )
51
51
. map ( AsyncBincodeStream :: from)
52
52
. map ( AsyncBincodeStream :: for_async)
53
- . map ( |t| multiplex:: MultiplexTransport :: new ( t, Tagger :: default ( ) ) ) ,
54
- )
53
+ . map ( |t| multiplex:: MultiplexTransport :: new ( t, Tagger :: default ( ) ) )
55
54
}
56
55
}
57
56
@@ -257,8 +256,8 @@ impl fmt::Debug for Table {
257
256
impl Service < Input > for Table {
258
257
type Error = TableError ;
259
258
type Response = <TableRpc as Service < Tagged < LocalOrNot < Input > > > >:: Response ;
260
- // existential once https://github.com/rust-lang/rust/issues/53443 is fixed
261
- type Future = Box < Future < Item = Tagged < ( ) > , Error = Self :: Error > + Send > ;
259
+ // have to repeat types because https://github.com/rust-lang/rust/issues/57807
260
+ existential type Future : Future < Item = Tagged < ( ) > , Error = TableError > ;
262
261
263
262
fn poll_ready ( & mut self ) -> Poll < ( ) , Self :: Error > {
264
263
for s in & mut self . shards {
@@ -273,8 +272,7 @@ impl Service<Input> for Table {
273
272
// TODO: check each row's .len() against self.columns.len() -> WrongColumnCount
274
273
275
274
if self . shards . len ( ) == 1 {
276
- // when Box goes away, this becomes future::Either::A
277
- Box :: new (
275
+ future:: Either :: A (
278
276
self . shards [ 0 ]
279
277
. call (
280
278
if self . dst_is_local {
@@ -333,8 +331,7 @@ impl Service<Input> for Table {
333
331
}
334
332
}
335
333
336
- // when Box goes away, this becomes future::Either::B
337
- Box :: new (
334
+ future:: Either :: B (
338
335
wait_for
339
336
. fold ( ( ) , |_, _| Ok ( ( ) ) )
340
337
. map_err ( TableError :: from)
@@ -483,14 +480,12 @@ impl Table {
483
480
fn quick_n_dirty < Request > (
484
481
self ,
485
482
r : Request ,
486
- ) -> Box < Future < Item = Self , Error = AsyncTableError > + Send >
483
+ ) -> impl Future < Item = Table , Error = AsyncTableError > + Send
487
484
where
488
485
Request : Send + ' static ,
489
486
Self : Service < Request , Error = TableError > ,
490
487
<Self as Service < Request > >:: Future : Send ,
491
488
{
492
- // Box is needed for https://github.com/rust-lang/rust/issues/53984
493
- Box :: new (
494
489
self . ready ( )
495
490
. map_err ( |e| match e {
496
491
TableError :: TransportError ( e) => AsyncTableError :: from ( e) ,
@@ -504,8 +499,7 @@ impl Table {
504
499
error : e,
505
500
} ) ,
506
501
} )
507
- } ) ,
508
- )
502
+ } )
509
503
}
510
504
511
505
/// Insert a single row of data into this base table.
@@ -552,25 +546,25 @@ impl Table {
552
546
553
547
if key. len ( ) != self . key . len ( ) {
554
548
let error = TableError :: WrongKeyColumnCount ( self . key . len ( ) , key. len ( ) ) ;
555
- return Box :: new ( future:: err ( AsyncTableError {
549
+ return future :: Either :: A ( future:: err ( AsyncTableError {
556
550
table : Some ( self ) ,
557
551
error,
558
- } ) ) as Box < _ > ;
552
+ } ) ) ;
559
553
}
560
554
561
555
let mut set = vec ! [ Modification :: None ; self . columns. len( ) ] ;
562
556
for ( coli, m) in u {
563
557
if coli >= self . columns . len ( ) {
564
558
let error = TableError :: WrongColumnCount ( self . columns . len ( ) , coli + 1 ) ;
565
- return Box :: new ( future:: err ( AsyncTableError {
559
+ return future :: Either :: A ( future:: err ( AsyncTableError {
566
560
table : Some ( self ) ,
567
561
error,
568
- } ) ) as Box < _ > ;
562
+ } ) ) ;
569
563
}
570
564
set[ coli] = m;
571
565
}
572
566
573
- self . quick_n_dirty ( TableOperation :: Update { key, set } )
567
+ future :: Either :: B ( self . quick_n_dirty ( TableOperation :: Update { key, set } ) )
574
568
}
575
569
576
570
/// Perform a insert-or-update on this base table.
@@ -581,7 +575,7 @@ impl Table {
581
575
self ,
582
576
insert : Vec < DataType > ,
583
577
update : V ,
584
- ) -> Box < Future < Item = Self , Error = AsyncTableError > + Send >
578
+ ) -> impl Future < Item = Table , Error = AsyncTableError > + Send
585
579
where
586
580
V : IntoIterator < Item = ( usize , Modification ) > ,
587
581
{
@@ -592,7 +586,7 @@ impl Table {
592
586
593
587
if insert. len ( ) != self . columns . len ( ) {
594
588
let error = TableError :: WrongColumnCount ( self . columns . len ( ) , insert. len ( ) ) ;
595
- return Box :: new ( future:: err ( AsyncTableError {
589
+ return future :: Either :: A ( future:: err ( AsyncTableError {
596
590
table : Some ( self ) ,
597
591
error,
598
592
} ) ) ;
@@ -602,18 +596,18 @@ impl Table {
602
596
for ( coli, m) in update {
603
597
if coli >= self . columns . len ( ) {
604
598
let error = TableError :: WrongColumnCount ( self . columns . len ( ) , coli + 1 ) ;
605
- return Box :: new ( future:: err ( AsyncTableError {
599
+ return future :: Either :: A ( future:: err ( AsyncTableError {
606
600
table : Some ( self ) ,
607
601
error,
608
602
} ) ) ;
609
603
}
610
604
set[ coli] = m;
611
605
}
612
606
613
- self . quick_n_dirty ( TableOperation :: InsertOrUpdate {
607
+ future :: Either :: B ( self . quick_n_dirty ( TableOperation :: InsertOrUpdate {
614
608
row : insert,
615
609
update : set,
616
- } )
610
+ } ) )
617
611
}
618
612
619
613
/// Trace the next modification to this base table.
0 commit comments