@@ -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
. and_then ( |s| {
47
47
s. set_nodelay ( true ) ?;
@@ -54,8 +54,7 @@ impl Service<()> for TableEndpoint {
54
54
} )
55
55
. map ( AsyncBincodeStream :: from)
56
56
. map ( AsyncBincodeStream :: for_async)
57
- . map ( |t| multiplex:: MultiplexTransport :: new ( t, Tagger :: default ( ) ) ) ,
58
- )
57
+ . map ( |t| multiplex:: MultiplexTransport :: new ( t, Tagger :: default ( ) ) )
59
58
}
60
59
}
61
60
@@ -261,8 +260,8 @@ impl fmt::Debug for Table {
261
260
impl Service < Input > for Table {
262
261
type Error = TableError ;
263
262
type Response = <TableRpc as Service < Tagged < LocalOrNot < Input > > > >:: Response ;
264
- // existential once https://github.com/rust-lang/rust/issues/53443 is fixed
265
- type Future = Box < Future < Item = Tagged < ( ) > , Error = Self :: Error > + Send > ;
263
+ // have to repeat types because https://github.com/rust-lang/rust/issues/57807
264
+ existential type Future : Future < Item = Tagged < ( ) > , Error = TableError > ;
266
265
267
266
fn poll_ready ( & mut self ) -> Poll < ( ) , Self :: Error > {
268
267
for s in & mut self . shards {
@@ -277,8 +276,7 @@ impl Service<Input> for Table {
277
276
// TODO: check each row's .len() against self.columns.len() -> WrongColumnCount
278
277
279
278
if self . shards . len ( ) == 1 {
280
- // when Box goes away, this becomes future::Either::A
281
- Box :: new (
279
+ future:: Either :: A (
282
280
self . shards [ 0 ]
283
281
. call (
284
282
if self . dst_is_local {
@@ -337,8 +335,7 @@ impl Service<Input> for Table {
337
335
}
338
336
}
339
337
340
- // when Box goes away, this becomes future::Either::B
341
- Box :: new (
338
+ future:: Either :: B (
342
339
wait_for
343
340
. fold ( ( ) , |_, _| Ok ( ( ) ) )
344
341
. map_err ( TableError :: from)
@@ -487,14 +484,12 @@ impl Table {
487
484
fn quick_n_dirty < Request > (
488
485
self ,
489
486
r : Request ,
490
- ) -> Box < Future < Item = Self , Error = AsyncTableError > + Send >
487
+ ) -> impl Future < Item = Table , Error = AsyncTableError > + Send
491
488
where
492
489
Request : Send + ' static ,
493
490
Self : Service < Request , Error = TableError > ,
494
491
<Self as Service < Request > >:: Future : Send ,
495
492
{
496
- // Box is needed for https://github.com/rust-lang/rust/issues/53984
497
- Box :: new (
498
493
self . ready ( )
499
494
. map_err ( |e| match e {
500
495
TableError :: TransportError ( e) => AsyncTableError :: from ( e) ,
@@ -508,8 +503,7 @@ impl Table {
508
503
error : e,
509
504
} ) ,
510
505
} )
511
- } ) ,
512
- )
506
+ } )
513
507
}
514
508
515
509
/// Insert a single row of data into this base table.
@@ -556,25 +550,25 @@ impl Table {
556
550
557
551
if key. len ( ) != self . key . len ( ) {
558
552
let error = TableError :: WrongKeyColumnCount ( self . key . len ( ) , key. len ( ) ) ;
559
- return Box :: new ( future:: err ( AsyncTableError {
553
+ return future :: Either :: A ( future:: err ( AsyncTableError {
560
554
table : Some ( self ) ,
561
555
error,
562
- } ) ) as Box < _ > ;
556
+ } ) ) ;
563
557
}
564
558
565
559
let mut set = vec ! [ Modification :: None ; self . columns. len( ) ] ;
566
560
for ( coli, m) in u {
567
561
if coli >= self . columns . len ( ) {
568
562
let error = TableError :: WrongColumnCount ( self . columns . len ( ) , coli + 1 ) ;
569
- return Box :: new ( future:: err ( AsyncTableError {
563
+ return future :: Either :: A ( future:: err ( AsyncTableError {
570
564
table : Some ( self ) ,
571
565
error,
572
- } ) ) as Box < _ > ;
566
+ } ) ) ;
573
567
}
574
568
set[ coli] = m;
575
569
}
576
570
577
- self . quick_n_dirty ( TableOperation :: Update { key, set } )
571
+ future :: Either :: B ( self . quick_n_dirty ( TableOperation :: Update { key, set } ) )
578
572
}
579
573
580
574
/// Perform a insert-or-update on this base table.
@@ -585,7 +579,7 @@ impl Table {
585
579
self ,
586
580
insert : Vec < DataType > ,
587
581
update : V ,
588
- ) -> Box < Future < Item = Self , Error = AsyncTableError > + Send >
582
+ ) -> impl Future < Item = Table , Error = AsyncTableError > + Send
589
583
where
590
584
V : IntoIterator < Item = ( usize , Modification ) > ,
591
585
{
@@ -596,7 +590,7 @@ impl Table {
596
590
597
591
if insert. len ( ) != self . columns . len ( ) {
598
592
let error = TableError :: WrongColumnCount ( self . columns . len ( ) , insert. len ( ) ) ;
599
- return Box :: new ( future:: err ( AsyncTableError {
593
+ return future :: Either :: A ( future:: err ( AsyncTableError {
600
594
table : Some ( self ) ,
601
595
error,
602
596
} ) ) ;
@@ -606,18 +600,18 @@ impl Table {
606
600
for ( coli, m) in update {
607
601
if coli >= self . columns . len ( ) {
608
602
let error = TableError :: WrongColumnCount ( self . columns . len ( ) , coli + 1 ) ;
609
- return Box :: new ( future:: err ( AsyncTableError {
603
+ return future :: Either :: A ( future:: err ( AsyncTableError {
610
604
table : Some ( self ) ,
611
605
error,
612
606
} ) ) ;
613
607
}
614
608
set[ coli] = m;
615
609
}
616
610
617
- self . quick_n_dirty ( TableOperation :: InsertOrUpdate {
611
+ future :: Either :: B ( self . quick_n_dirty ( TableOperation :: InsertOrUpdate {
618
612
row : insert,
619
613
update : set,
620
- } )
614
+ } ) )
621
615
}
622
616
623
617
/// Trace the next modification to this base table.
0 commit comments