From 97d6ca0caa8d06917700c0509936fac6dab7fef9 Mon Sep 17 00:00:00 2001 From: Jannes Brands Date: Thu, 22 Feb 2024 22:45:00 +0100 Subject: [PATCH] fix --- examples/forward.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/forward.rs b/examples/forward.rs index 07ed21a..cd0ebd7 100644 --- a/examples/forward.rs +++ b/examples/forward.rs @@ -27,12 +27,12 @@ struct Options { } #[cfg(target_os = "linux")] -fn open_can_interface() -> (CanSocket, CanSocket) { - let mut input = CanSocket::open(&opts.input_interface) - .expect("The given input interface cannot be opened!"); +fn open_can_interface(input_name: &str, output_name: &str) -> (CanSocket, CanSocket) { + let mut input = + CanSocket::open(input_name).expect("The given input interface cannot be opened!"); - let mut output = CanSocket::open(&opts.output_interface) - .expect("The given output interface cannot be opened!"); + let mut output = + CanSocket::open(output_name).expect("The given output interface cannot be opened!"); (input, output) } @@ -54,9 +54,8 @@ fn main() { ); #[cfg(target_os = "linux")] - { - let (input, output) = open_can_interface(); - + |opts: Options| { + let (input, output) = open_can_interface(&opts.input_interface, &opts.output_interface); input .set_nonblocking(true) .expect("Could not set input bus to non-blocking!");