object_rainbow/
runtime_array.rs1use crate::*;
2
3#[derive(
4 Debug, ToOutput, InlineOutput, ListHashes, Topological, PartialEq, ParseAsInline, Clone,
5)]
6pub struct RuntimeArray<T>(pub Vec<T>);
7
8impl<T> Deref for RuntimeArray<T> {
9 type Target = Vec<T>;
10
11 fn deref(&self) -> &Self::Target {
12 &self.0
13 }
14}
15
16impl<T> DerefMut for RuntimeArray<T> {
17 fn deref_mut(&mut self) -> &mut Self::Target {
18 &mut self.0
19 }
20}
21
22impl<A> FromIterator<A> for RuntimeArray<A> {
23 fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self {
24 Self(iter.into_iter().collect())
25 }
26}
27
28impl<T: InlineOutput> InlineOutput for RuntimeArray<T> {}
31
32impl<T: ParseInline<I::WithExtra<E>>, I: PointInput<Extra = (u64, E)>, E: 'static + Clone>
33 ParseInline<I> for RuntimeArray<T>
34{
35 fn parse_inline(input: &mut I) -> crate::Result<Self> {
36 let (n, extra) = input.extra().clone();
37 (0..n)
38 .map(|_| input.parse_inline_extra(extra.clone()))
39 .collect()
40 }
41}