Hacker News new | past | comments | ask | show | jobs | submit login

Exactly. ! for macros was a mistake anyway, I guess that's why they stopped using it with await.



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.


Perhaps macros shouldn't do things that aren't "obvious" then?


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.


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




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

Search: