Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
unwrap_or_else of Result<T, E> takes a closure of FnOnce(E) -> T, i.e. you must return a T, which in this case is Config.
Your closure ends with process::exit(); (semicolon!) which means the closure evaluates to the unit type (), which is wrong
The compiler can't even get to the phase of checking whether process is in scope because your types are messed up
As a quick fix try removing the semicolon after process::exit(). Since it returns !, the never type (aka. the function cannot return), it should(?) then type check -
Voxera115852yCould it be that the undeclared process caused rust to not understand?
But yrs it should have noticed the inner error also in that case, unless it has with the order of parsing to do.
It could be that it could not figure out if process actually was an error due to thinking there was a mismatch in the outer code.
But I have not worked with rust, I only know it has generally better errors than most.
Especially compared to c or c++ ;)
At least back when I used C. -
hinst13152y@12bitfloat sir in my case the error is eliminated entirely if I uncomment `use std::process;` so the error is very specific and unrelated to Config
-
@hinst Yes but that's not specific to Config nor your situation. This code (https://play.rust-lang.org//... ) is effectively identical to yours and it prints both errors
I don't know if your rust-analyzer install is busted but it sure as heck isn't a problem with Rust
Related Rants
â›” Rust error: expected Config, found ().
💡 Actual error: process is undeclared.
The actual error has no relation to the error reported by the Rust code checker. So bad
random
rust