File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 6
6
///
7
7
/// Similar to C11 [`_Static_assert`] and C++11 [`static_assert`].
8
8
///
9
+ /// An optional panic message can be supplied after the expression.
10
+ /// Currently only a string literal without formatting is supported
11
+ /// due to constness limitations of the [`assert!`] macro.
12
+ ///
9
13
/// The feature may be added to Rust in the future: see [RFC 2790].
10
14
///
11
15
/// [`_Static_assert`]: https://en.cppreference.com/w/c/language/_Static_assert
25
29
/// x + 2
26
30
/// }
27
31
/// static_assert!(f(40) == 42);
32
+ /// static_assert!(f(40) == 42, "f(x) must add 2 to the given input.");
28
33
/// ```
29
34
#[ macro_export]
30
35
macro_rules! static_assert {
31
- ( $condition: expr) => {
32
- const _: ( ) = core:: assert!( $condition) ;
36
+ ( $condition: expr $ ( , $arg : literal ) ? ) => {
37
+ const _: ( ) = core:: assert!( $condition $ ( , $arg ) ? ) ;
33
38
} ;
34
39
}
You can’t perform that action at this time.
0 commit comments