File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,10 @@ macro_rules! __if_chain {
152152 $( $pat) |+ => __if_chain! { @expand $other $( $tt) + }
153153 }
154154 } ;
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+ } ;
155159 ( @expand $other: block if let $( $pat: pat) |+ = $expr: expr; $( $tt: tt) +) => {
156160 match $expr {
157161 $( $pat) |+ => __if_chain! { @expand $other $( $tt) + } ,
@@ -236,4 +240,17 @@ mod tests {
236240 else { panic!( ) ; }
237241 }
238242 }
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+ }
239256}
You can’t perform that action at this time.
0 commit comments