fcla 0.1.0

Command line argument parsing
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::internal::*;

impl<T: FromArgs, const LENGTH: usize> FromArgs for [T; LENGTH] {
    // todo replace this with a non-allocating implementation
    fn from_args<S: Source + ?Sized>(args: &mut Args<S>) -> FromArgsResult<Self> {
        Ok((0..LENGTH)
            .map(|index| args.parse(Ident::Unnamed(index)))
            .collect::<Result<Vec<_>, _>>()?
            .try_into()
            // we don't use `expect` here because we're not concerned with the contents of the vec, only its length
            .unwrap_or_else(|_| unreachable!("there should always be `LENGTH` elements")))
    }
}