pacak / bpaf

Command line parser with applicative interface
337 stars 17 forks source link

impl<T> Parser<T> for Vec<Box<dyn Parser<T>>> #314

Open pacak opened 10 months ago

pacak commented 10 months ago

Should make choice a bit more efficient still. todo!() needs to use some bits from ParseOrElse::eval

  impl<T> Parser<T> for Vec<Box<dyn Parser<T>>> {
      fn eval(&self, args: &mut State) -> Result<T, Error> {
          todo!()
      }

      fn meta(&self) -> Meta {
          let xs = self
              .iter()
              .filter_map(|p| match p.meta() {
                  Meta::Skip => None,
                  m => Some(m),
              })
              .collect::<Vec<_>>();
          if xs.is_empty() {
              Meta::Skip
          } else {
              Meta::Or(xs)
          }
      }
  }