It'd be nice if we can specify a value (not a type) for the type part of the macro. This allows us to perform parameterized read+conversion, for example
struct DirectedGraph(usize, usize);
impl ReadWith for DirectedGraph {
type Output = Vec<Vec<usize>>;
fn read<R: BufRead, S: Source<R>>(&self, source: &mut S) -> Self::Output {
input! {
from source,
edges: [(Usize1, Usize1); self.m],
};
let mut g = vec![vec![]; self.n];
for e in edges {
g[e.0].push(e.1);
}
e
}
}
input! {
n: usize,
m: usize,
some_random_values: [i32; n],
g: with DirectedGraph(n, m),
}
. Here, with distinguishes if input! should treat it as a type or a value.
It'd be nice if we can specify a value (not a type) for the type part of the macro. This allows us to perform parameterized read+conversion, for example
. Here,
with
distinguishes ifinput!
should treat it as a type or a value.