Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an enum instead of a boolean to indicate the closed-ness of a fields constraint in function parameters #224

Open
popematt opened this issue Oct 17, 2024 · 0 comments
Labels
bug Something isn't working v1.0.0 requirement

Comments

@popematt
Copy link
Contributor

#218 added a boolean paramter to indicate whether fields are closed or open. In the interest of readability, we should change this to an enum before releasing v1.0.0 of ion-schema-rust.

Note that this is specifically calling out function parameters/arguments. It's fine to have a boolean as the return type of is_closed() because the function name describes the return value. However, something like fields(my_fields_map, true) has nothing to indicate the meaning of the boolean, whereas fields(my_fields_map, FieldContent::Closed) is very clear.

See e.g. https://blakesmith.me/2019/05/07/rust-patterns-enums-instead-of-booleans.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v1.0.0 requirement
Projects
None yet
Development

No branches or pull requests

1 participant