@rillian This might be it.
I present to you the legendary `????` operator.
"what is ???? ????" 😉
It's 4 chained `?` operators. That's a shorthand to convert a type like `Result<Result<Result<Result<T, _>, _>, _>, _>` into just `T` if all the results are successful. Otherwise if any one of them is an error, the error gets returned from whatever function this code is inside.
@wertercatt @antonok If you wanted lower-level, the rust standard library has a `Result` enum which is often used for the return value of functions. Its variants represent either success, wrapping the actual value, or an error. Putting `?` in an expression unwraps successful results, or returns if it's an error. So errors bubble up, but the success path stays tidy.
So `??` just unwraps nested Results: a result of a result if you will.
See https://doc.rust-lang.org/book/ch02-00-guessing-game-tutorial.html#handling-potential-failure-with-result and https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html
@antonok @rillian Here you go: Result::and_then
https://doc.rust-lang.org/std/result/enum.Result.html#method.and_then
@antonok Looks a bit overengineered tho. This would be much simpler:
let s = source.map_or(std::ptr::null(), |x| x.as_ptr());
// other params
let res = unsafe libc::mount(...)?;