Skip to content

Commit 47c68bf

Browse files
author
Daniel Norman
committed
Geesh, that was a silly and unnecessarily hard-to-find bug. The compiler was getting hung up on trying to infer the possible types of Transport trait implementations, as this determination is indeed circular. The issue with the compiler is not necessarily that it's unable to infer this, but that isn't giving a clearer error message, or a suggestion as to what to do
1 parent 4ab0fdf commit 47c68bf

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/network/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct NetworkInternals {
1515
next_slab_id: u32,
1616
slabs: Vec<WeakSlab>,
1717
slab_refs: Vec<SlabRef>,
18-
transports: Vec<Arc<Transport>>
18+
transports: Vec<Arc<Transport + Send + Sync>>
1919
}
2020

2121
pub struct NetworkShared {
@@ -47,7 +47,7 @@ impl Network {
4747

4848
net
4949
}
50-
pub fn add_transport (&self, transport: Arc<Transport> ) {
50+
pub fn add_transport (&self, transport: Arc<Transport + Send + Sync> ) {
5151
let mut internals = self.shared.internals.lock().unwrap();
5252
internals.transports.push(transport);
5353
}

src/network/transport/transmitter.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub trait DynamicDispatchTransmitter {
88
}
99

1010
enum TransmitterInternal {
11-
Local(), // TODO: How to use
11+
Local(), // TODO: How to use
1212
Simulator(SimulatorTransmitter),
1313
Dynamic(Box<DynamicDispatchTransmitter + Send + Sync>)
1414
}
@@ -19,8 +19,10 @@ pub struct Transmitter {
1919

2020
impl Transmitter {
2121
/// Create a new transmitter associated with a local slab.
22-
pub fn new_local(slab: &Slab) -> Self {
23-
unimplemented!()
22+
pub fn new_local(_slab: &Slab) -> Self {
23+
Self {
24+
internal: TransmitterInternal::Local()
25+
}
2426
}
2527
/// Create a new transmitter associated with a local simulator transmitter.
2628
pub fn new_simulated(sim_tx: SimulatorTransmitter) -> Self {
@@ -44,7 +46,7 @@ impl Transmitter {
4446
Simulator(ref tx) => {
4547
tx.send(from, memo);
4648
}
47-
Dynamic(ref tx) => {
49+
Dynamic(ref _tx) => {
4850
unimplemented!()
4951
}
5052
}

0 commit comments

Comments
 (0)