Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Throw an exception

proving the point of the article even further



You would actually use a Result type:

  use std::io;
  
  pub fn read(path: Path) -> io::Result<Bytes> {
    File::open(path)?.read_to_end()
  }


Sure, if you are allowed to change the signature, makes it look more ugly than just returning Bytes though




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: