News for hackers. Stuff that matters.
Re:Fast Rust Builds by yakubin on Sunday September 05, 2021 @06:18PM (#28428329)
> File.open(path).orReturnErr()

Method syntax is reserved for functions. There are no method syntax macros. Since a return in a function terminates execution of this function, and not its caller, your example would not work.

Re:Fast Rust Builds by zozbot234 on Sunday September 05, 2021 @07:21PM (#28428714)
Right, so this should really be .orReturnErr , by analogy with .await . We just overload the dot symbol to mean both "method call" and "weird monadic stuff is happening here".
Re:Fast Rust Builds by simon_o on Monday September 06, 2021 @06:48AM (#28432409)
Exactly. ! for macros was a mistake anyway, I guess that's why they stopped using it with await.
Re:Fast Rust Builds by yakubin on Monday September 06, 2021 @07:28AM (#28432656)
It wasn't. Without "!" it isn't obvious that you cannot take a:

  let a: Result<u8, u8> = /* whatever *;
  let b = match a {
      Ok(v) => Ok(foo(v)),
      e => e,
  };
and transform it into:

  let a: Result<u8, u8> = /* whatever *;
  let b = a.map(foo);
if "foo" is a macro. When you substitute "foo!" for all the "foo" above, it is obvious.
Re:Fast Rust Builds by simon_o on Monday September 06, 2021 @07:32AM (#28432670)
Perhaps macros shouldn't do things that aren't "obvious" then?
Re:Fast Rust Builds by infogulch on Monday September 06, 2021 @09:11AM (#28433316)
As a rule, rust rejects the "simpler" choice that instead lay the burden of correctness at the feet of the user. I'm glad they keep a hard line here.
Re:Fast Rust Builds by steveklabnik on Monday September 06, 2021 @11:43AM (#28434805)
> I guess that's why they stopped using it with await

await cannot be a macro, it has to be built into the language, and so it doesn't have the ! because it's not one.

Re:Fast Rust Builds by simon_o on Monday September 06, 2021 @05:50AM (#28432056)
You realize the syntax has changed more than that?
Re:Fast Rust Builds by yakubin on Monday September 06, 2021 @07:21AM (#28432604)
Yes, but "->" vs ":", or kinds of brackets are superficial, while method syntax has a specific meaning.