From 60099aed50b89daef29543c4700470e566c48798 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 11 Feb 2020 21:30:39 +0100 Subject: =?UTF-8?q?Parse=20tuples=20and=20objects=20=F0=9F=8D=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generalizes the parsing of tuples, objects and function arguments into generic comma-separated collections. --- src/syntax/func/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/syntax/func') diff --git a/src/syntax/func/mod.rs b/src/syntax/func/mod.rs index 0c5b4447..53bbc14e 100644 --- a/src/syntax/func/mod.rs +++ b/src/syntax/func/mod.rs @@ -1,5 +1,6 @@ //! Primitives for argument parsing in library functions. +use std::iter::FromIterator; use crate::error::{Error, Errors}; use super::expr::{Expr, Ident, Tuple, Object, Pair}; use super::span::{Span, Spanned}; @@ -55,6 +56,16 @@ impl FuncArgs { } } +impl FromIterator for FuncArgs { + fn from_iter>(iter: I) -> Self { + let mut args = FuncArgs::new(); + for item in iter.into_iter() { + args.add(item); + } + args + } +} + /// Either a positional or keyword argument. #[derive(Debug, Clone, PartialEq)] pub enum FuncArg { -- cgit v1.2.3