4

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

std::io::Result<()>

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

kmdreko
  • 42,554
  • 6
  • 57
  • 106
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114

1 Answers1

7

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>.

Brian61354270
  • 8,690
  • 4
  • 21
  • 43