I am porting C++ class which contains file handle, and its constructor takes as input argument the path to a filename. If the file at specified path can not be opened for whatever reason, the constructor throws an exception which is caught by the child class, and so on until the caller catches it and converts the chain of exceptions into the success status value.
I am trying to write the Rust equivalent, but haven't gone too far with structuring the handling of the failures from within the constructor which merely fills the list of member variables with initializer values
This will automatically return the error should there be an error while opening the file. Note that the Result type used here is the special type declaration in the IO module. See std::io::Result for more on the result, and std::io::Error for more on the errors possible.
Edit: ? will apparently not discard errors when converting to and option from a Result, so I inserted an .ok() call in there. Also, I had forgotten to return the correct type; so wrapping the struct in Ok and Some fixes it. I apologize for the mixup!