jean_io 0.1.0

I/O library feature for jean
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::str::FromStr;

use pest::{iterators::Pair, RuleType};

pub fn cast<'a, T, R>(pair: &Pair<'a, R>) -> T
where
  T: Default + FromStr,
  R: RuleType,
{
  pair.as_str().parse::<T>().unwrap_or_default()
}

pub fn expand<'a, R>(pair: &Pair<'a, R>) -> Vec<Pair<'a, R>>
where
  R: RuleType,
{
  pair.clone().into_inner().collect::<Vec<Pair<'a, R>>>()
}