We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b428a1c commit cccdd2cCopy full SHA for cccdd2c
src/lib.rs
@@ -152,6 +152,10 @@ macro_rules! __if_chain {
152
$($pat)|+ => __if_chain! { @expand $other $($tt)+ }
153
}
154
};
155
+ (@expand $other:block let $ident:ident:$ty:ty = $expr:expr; $($tt:tt)+) => {
156
+ let $ident:$ty = $expr;
157
+ __if_chain! { @expand $other $($tt)+ }
158
+ };
159
(@expand $other:block if let $($pat:pat)|+ = $expr:expr; $($tt:tt)+) => {
160
match $expr {
161
$($pat)|+ => __if_chain! { @expand $other $($tt)+ },
@@ -236,4 +240,17 @@ mod tests {
236
240
else { panic!(); }
237
241
238
242
243
+
244
+ #[test]
245
+ fn let_type_annotation_patterns() {
246
+ let mut x: u32 = 1;
247
+ if_chain! {
248
+ if x > 0;
249
+ let y: u32 = 2;
250
251
+ then { x += y; }
252
+ else { x += 1; }
253
254
+ assert_eq!(x, 3);
255
+ }
239
256
0 commit comments