News for hackers. Stuff that matters.

baysmith

Re:Rust's Ugly Syntax on Friday January 27, 2023 @04:13PM (#34551939)
I think using . for both field/method access and name pathing would hurt readability and make name lookup more difficult. Perhaps replace :: with a backtick instead?

  use std;
  use std`fs`File;
  pub fn read<P: AsRef<Path>>(path: P) -> io`Result<Vec<u8>> {
    fn inner(path: &Path) -> io`Result<Vec<u8>> {
      let mut file = File`open(path)?;
      let mut bytes = Vec`new();
      file.read_to_end(&mut bytes)?;
      Ok(bytes)
    }
    inner(path.as_ref())
  }