We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
assert_type_in
Assertion that the supplied type must be one of multiple listed types.
One possible (although not so elegant) implementation is like this:
macro_rules! assert_type_in { ($label:ident; $type:ty, $($in:ty),*) => { mod $label { $(fn mux(_: $in) {})* fn _(v: $type) { mux(v); } } }; }
The text was updated successfully, but these errors were encountered:
I came up with this which seems to work fine (playground):
macro_rules! assert_type_in { ($t:ty: $($l:ty),+ $(,)*) => { { trait InList {} $(impl InList for $l {})+ fn in_list<T: ?Sized + InList>() {} let _ = in_list::<$t>; } } } fn main() { assert_type_in!(u8: u8, u16); }
Sorry, something went wrong.
No branches or pull requests
Assertion that the supplied type must be one of multiple listed types.
One possible (although not so elegant) implementation is like this:
The text was updated successfully, but these errors were encountered: