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
@compiles(expr: var) bool
Takes an expression and returns a bool indicating whether the expression compiles.
bool
This can be used to create test failure cases or implement sophisticated compile-time logic for fine-grained control over "generics" specialization.
Dlang equivalent __traits(compiles, <EXPR>) (https://dlang.org/spec/traits.html#compiles)
__traits(compiles, <EXPR>)
pub fn foo(comptime T: type) type { switch (T) { builtin.TypeInfo.Pointer => { return T; } else => @compileError("foo requires Pointer types but got " ++ @typeName(T)); } } test "foo" { // make sure this fails std.testing.expect(!@compiles(foo(u8))); }
The text was updated successfully, but these errors were encountered:
Duplicate of #513
Sorry, something went wrong.
No branches or pull requests
Takes an expression and returns a
bool
indicating whether the expression compiles.This can be used to create test failure cases or implement sophisticated compile-time logic for fine-grained control over "generics" specialization.
Example: used for test failure cases
The text was updated successfully, but these errors were encountered: