We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6d682c9 commit 7cf1f18Copy full SHA for 7cf1f18
src/libcore/tests/nonzero.rs
@@ -98,3 +98,26 @@ fn test_match_option_string() {
98
None => panic!("unexpected None while matching on Some(String { ... })")
99
}
100
101
+
102
+mod atom {
103
+ use core::num::NonZeroU32;
104
105
+ #[derive(PartialEq, Eq)]
106
+ pub struct Atom {
107
+ index: NonZeroU32, // private
108
+ }
109
+ pub const FOO_ATOM: Atom = Atom { index: unsafe { NonZeroU32::new_unchecked(7) } };
110
+}
111
112
+macro_rules! atom {
113
+ ("foo") => { atom::FOO_ATOM }
114
115
116
+#[test]
117
+fn test_match_nonzero_const_pattern() {
118
+ match atom!("foo") {
119
+ // Using as a pattern is supported by the compiler:
120
+ atom!("foo") => {}
121
+ _ => panic!("Expected the const item as a pattern to match.")
122
123
0 commit comments