you are viewing a single comment's thread
view the rest of the comments
[–] 8 points 6 months ago (3 children)

Rust doesn't need this as much because it has enums so you can just do create_user(user, Role::Admin, Notify::None).

  • source
  • parent
  • hideshow 3 child comments
  • [–] 9 points 6 months ago (2 children)

    you can have a better data structure in any language, but rarely someone will bother doing that for booleans

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 6 months ago

    Yeah I do wonder if we need an easier way to declare these things because programmers are lazy and even in Rust I wouldn't always bother.

    You can kind of do it in Typescript with strings:

    function create_user(role: "admin" | "normal")
    

    But of course the downside is they are strings at runtime. I'm sure it's possible though.

  • source
  • parent