Converts a collection of `ArgSpan`s passed to a function or array reference to a collection of expressions with proper validation.
(spans: Vec<ArgSpan>)
| 56 | /// Converts a collection of `ArgSpan`s passed to a function or array reference to a collection |
| 57 | /// of expressions with proper validation. |
| 58 | pub(crate) fn argspans_to_exprs(spans: Vec<ArgSpan>) -> Vec<Expr> { |
| 59 | let nargs = spans.len(); |
| 60 | let mut exprs = Vec::with_capacity(spans.len()); |
| 61 | for (i, span) in spans.into_iter().enumerate() { |
| 62 | debug_assert!( |
| 63 | (span.sep == ArgSep::End || i < nargs - 1) |
| 64 | || (span.sep != ArgSep::End || i == nargs - 1) |
| 65 | ); |
| 66 | match span.expr { |
| 67 | Some(expr) => exprs.push(expr), |
| 68 | None => unreachable!(), |
| 69 | } |
| 70 | } |
| 71 | exprs |
| 72 | } |
| 73 | |
| 74 | /// Operators that can appear within an expression. |
| 75 | /// |