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

Macros for concise precondition checks #663

Open
anorth opened this issue Sep 15, 2022 · 1 comment
Open

Macros for concise precondition checks #663

anorth opened this issue Sep 15, 2022 · 1 comment
Labels
cleanup good first issue Good for newcomers

Comments

@anorth
Copy link
Member

anorth commented Sep 15, 2022

We have lots of code like this:

                        if ids.len() != 1 {
                            return Err(actor_error!(
                                illegal_argument,
                                "expected 1 allocation ID, got {:?}",
                                ids
                            ));
                        }

Write a couple of macros so we can write

require_argument!(ids.len() == 1, "expected 1 allocation ID, got {:?}", ids)

and similar for state and "forbidden"-type errors. (Macros are necessary for var-args)

@anorth anorth added good first issue Good for newcomers cleanup labels Sep 15, 2022
@Stebalien
Copy link
Member

Note: for fixed-length parameter arrays, we should probably just be using arrays. But otherwise, yeah, require_argument would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants