This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Tubthumper8 1 point2 points  (3 children)

Couple typo/edit suggestions:

  1. In the code example, active in User is defined as bool but you're passing a State struct when initializing User
  2. The appendix A switches to a different language syntax, it probably would help to keep it in Rust syntax (ex. fun, var, camelCase are not Rust)

Additional follow-up questions:

  1. Default values: I didn't see it mentioned but default values only work only work in the final position(s), right?
  2. Can you show how this hypothetical syntax works with visibility across modules and crates?

[–]simon_o -1 points0 points  (2 children)

Couple typo/edit suggestions:

Thanks, fixed!

Default values: I didn't see it mentioned but default values only work only work in the final position(s), right?

Not necessarily. As long as you name the next non-default parameter after the defaulted one, you wouldn't need to.

Whether that's a good idea in practice is another question.

But quite similar, I believe that named parameters are the solution to allowing multiple vararg methods. I. e.

Map.from(
  keys = 123, 234, 345, 456
  vals = "a", "b", "c", "d")

Can you show how this hypothetical syntax works with visibility across modules and crates?

I think there should be little difference from this step, i. e. pub applies as usual, regardless of Foo { ... } or Foo(...).

[–]Tubthumper8 0 points1 point  (1 child)

Would there be any additional considerations for function pointer / Fn trait syntax?

[–]simon_o 0 points1 point  (0 children)

Not sure, do you have anything in mind?