Parses `case when {cond} then {then} else {els} end`.
(input: ParseStream)
| 990 | |
| 991 | /// Parses `case when {cond} then {then} else {els} end`. |
| 992 | fn parse_case(input: ParseStream) -> Result { |
| 993 | input.parse::<kw::case>()?; |
| 994 | if input.peek(kw::when) { |
| 995 | input.parse::<kw::when>()?; |
| 996 | let cond = parse_expr(input)?; |
| 997 | input.parse::<kw::then>()?; |
| 998 | let then = parse_expr(input)?; |
| 999 | input.parse::<syn::Token![else]>()?; |
| 1000 | let els = parse_expr(input)?; |
| 1001 | input.parse::<kw::end>()?; |
| 1002 | Ok(MirScalarExpr::If { |
| 1003 | cond: Box::new(cond), |
| 1004 | then: Box::new(then), |
| 1005 | els: Box::new(els), |
| 1006 | }) |
| 1007 | } else { |
| 1008 | Err(Error::new(input.span(), "expected 'when' after 'case'")) |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | pub fn parse_column(input: ParseStream) -> Result { |
| 1013 | Ok(MirScalarExpr::column(parse_column_index(input)?)) |
no test coverage detected