diff options
author | Aram Drevekenin <aram@poor.dev> | 2019-10-20 03:02:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-20 03:02:13 +0200 |
commit | 20085c848166d812b491ee2d585d635a9cc0d7ed (patch) | |
tree | ca759aa656b33822bb2fbb3d8b078e1e4cce3d37 | |
parent | 0229b2e8ec46a1e37bb8d332d9c2f6a6f96645e4 (diff) | |
parent | a47f1efa5be198642642103dca5dfcaa926da4bb (diff) |
fix(style): compiler warnings
Address compiler warnings
-rw-r--r-- | src/main.rs | 10 | ||||
-rw-r--r-- | src/network/sniffer.rs | 4 | ||||
-rw-r--r-- | src/os/linux.rs | 6 | ||||
-rw-r--r-- | src/tests/fakes/fake_input.rs | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index 383d59b..86abf5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,12 +62,12 @@ fn try_main() -> Result<(), failure::Error> { pub struct OsInput { pub network_interface: NetworkInterface, - pub network_frames: Box<DataLinkReceiver>, + pub network_frames: Box<dyn DataLinkReceiver>, pub get_open_sockets: fn() -> HashMap<Connection, String>, - pub keyboard_events: Box<Iterator<Item = Event> + Send>, - pub lookup_addr: Box<Fn(&IpAddr) -> Option<String> + Send>, - pub on_winch: Box<Fn(Box<Fn()>) + Send>, - pub cleanup: Box<Fn() + Send>, + pub keyboard_events: Box<dyn Iterator<Item = Event> + Send>, + pub lookup_addr: Box<dyn Fn(&IpAddr) -> Option<String> + Send>, + pub on_winch: Box<dyn Fn(Box<dyn Fn()>) + Send>, + pub cleanup: Box<dyn Fn() + Send>, } pub fn start<B>(terminal_backend: B, os_input: OsInput) diff --git a/src/network/sniffer.rs b/src/network/sniffer.rs index 4957681..e527df3 100644 --- a/src/network/sniffer.rs +++ b/src/network/sniffer.rs @@ -40,11 +40,11 @@ impl Direction { pub struct Sniffer { network_interface: NetworkInterface, - network_frames: Box<DataLinkReceiver>, + network_frames: Box<dyn DataLinkReceiver>, } impl Sniffer { - pub fn new(network_interface: NetworkInterface, network_frames: Box<DataLinkReceiver>) -> Self { + pub fn new(network_interface: NetworkInterface, network_frames: Box<dyn DataLinkReceiver>) -> Self { Sniffer { network_interface, network_frames, diff --git a/src/os/linux.rs b/src/os/linux.rs index f231d12..a7cbe56 100644 --- a/src/os/linux.rs +++ b/src/os/linux.rs @@ -29,7 +29,7 @@ impl Iterator for KeyboardEvents { fn get_datalink_channel( interface: &NetworkInterface, -) -> Result<Box<DataLinkReceiver>, failure::Error> { +) -> Result<Box<dyn DataLinkReceiver>, failure::Error> { let mut config = Config::default(); config.read_timeout = Some(time::Duration::new(0, 1)); match datalink::channel(interface, config) { @@ -89,11 +89,11 @@ fn lookup_addr(ip: &IpAddr) -> Option<String> { ::dns_lookup::lookup_addr(ip).ok() } -fn sigwinch() -> (Box<Fn(Box<Fn()>) + Send>, Box<Fn() + Send>) { +fn sigwinch() -> (Box<dyn Fn(Box<dyn Fn()>) + Send>, Box<dyn Fn() + Send>) { let signals = Signals::new(&[signal_hook::SIGWINCH]).unwrap(); let on_winch = { let signals = signals.clone(); - move |cb: Box<Fn()>| { + move |cb: Box<dyn Fn()>| { for signal in signals.forever() { match signal { signal_hook::SIGWINCH => cb(), diff --git a/src/tests/fakes/fake_input.rs b/src/tests/fakes/fake_input.rs index 831d4fb..04c5231 100644 --- a/src/tests/fakes/fake_input.rs +++ b/src/tests/fakes/fake_input.rs @@ -137,14 +137,14 @@ pub fn get_interface() -> NetworkInterface { pub fn create_fake_lookup_addr( ips_to_hosts: HashMap<IpAddr, String>, -) -> Box<Fn(&IpAddr) -> Option<String> + Send> { +) -> Box<dyn Fn(&IpAddr) -> Option<String> + Send> { Box::new(move |ip| match ips_to_hosts.get(ip) { Some(host) => Some(host.clone()), None => None, }) } -pub fn create_fake_on_winch(should_send_winch_event: bool) -> Box<Fn(Box<Fn()>) + Send> { +pub fn create_fake_on_winch(should_send_winch_event: bool) -> Box<dyn Fn(Box<dyn Fn()>) + Send> { Box::new(move |cb| { if should_send_winch_event { thread::sleep(time::Duration::from_secs(1)); |