Rust doesn't need this as much because it has enums so you can just do create_user(user, Role::Admin, Notify::None).
- Posts
- 2
- Comments
- 1231
- Joined
- 3 yr. ago
- Posts
- 2
- Comments
- 1231
- Joined
- 3 yr. ago
- JumpDeleted
Permanently Deleted
Permanently Deleted
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.