Hi I am having trouble knowing how to pass a None type using the explicit trait it wraps.
I have the following function
pub async fn run(verbosity: u64, mut output_override: Option<Box<impl output::YosemiteOutput>>) -> Result<(), Box<dyn Error>> {
I call this method where the output_override is based on command line options like
match output_type {
OutputType::console => {
run(verbosity, Some(Box::new(outputs::console_output::ConsoleOutput::new()))).await
},
OutputType::postgres => {
run(verbosity, Some(Box::new(outputs::postgres_output::PostgresOutput::new()))).await
},
_ => {
run(verbosity, do_conversion, None).await // causes error
}
}
Without the default option things work fine but when I try to pass None I get the error
type inside `async` block must be known in this context
--> src/main.rs:441:13
|
441 | run(verbosity, None).await
| ^^^ type inside `async` block must be known in this context
--> src/main.rs:441:13
|
441 | run(config_path, campus_name, requested_ip, requested_point_name, verbosity, do_conversion, None).await
| ^^^ cannot infer type for type parameter `impl output::YosemiteOutput` declared on the function `run`
|
note: the type is part of the `async` block because of this `await`
--> src/main.rs:441:13
|
441 | run(config_path, campus_name, requested_ip, requested_point_name, verbosity, do_conversion, None).await
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ declared on the function `run`
|
note: the type is part of the `async` block because of this `await`
--> src/main.rs:441:13
|
441 | run(verbosity, None).await
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I not sure what the error is telling me. How can I explicitly pass the type for that None using the explicit trait ?