What does Result<()> without the error type mean?

I was looking at the std::env::current_dir documentation and this caught my attention:


I thought a Result should have a T and an E. How can you substitute them with ()?


  • std::io::Result is a type alias specific to the std::io module, which is defined as

    type Result<T> = Result<T, ::std::io::Error>;

    Essentially, it's a std::result::Result with the error type prefilled as a std::io::Error. Using this type only requires one type parameter, which corresponds to the "ok" type T in Result<T,E>.