diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-02-11 21:30:39 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-02-11 21:30:39 +0100 |
| commit | 60099aed50b89daef29543c4700470e566c48798 (patch) | |
| tree | e465b122f68c777d46a08f1074f52bbd930a19ec /src/syntax/func | |
| parent | 5badb4e8ff1f8e055f5c1960d1d9803ee4d832fc (diff) | |
Parse tuples and objects 🍒
Generalizes the parsing of tuples, objects and function arguments into generic comma-separated collections.
Diffstat (limited to 'src/syntax/func')
| -rw-r--r-- | src/syntax/func/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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<FuncArg> for FuncArgs { + fn from_iter<I: IntoIterator<Item=FuncArg>>(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 { |
