teleparse/tp_impl/
boxed.rs1use crate::production_passthrough;
2use crate::syntax::{Metadata, Result as SynResult};
3use crate::{Parser, Pos, Produce, Production, Span, ToSpan};
4
5impl<T: Production> Production for Box<T> {
6 production_passthrough!(T);
7}
8
9impl<T: ToSpan> ToSpan for Box<T> {
10 fn lo(&self) -> Pos {
11 self.as_ref().lo()
12 }
13 fn hi(&self) -> Pos {
14 self.as_ref().hi()
15 }
16 fn span(&self) -> Span {
17 self.as_ref().span()
18 }
19}
20
21impl<T: Produce> Produce for Box<T> {
22 type Prod = Box<T::Prod>;
23
24 fn produce(
25 parser: &mut Parser<'_, <Self::Prod as Production>::L>,
26 meta: &Metadata<<Self::Prod as Production>::L>,
27 ) -> SynResult<Self, <Self::Prod as Production>::L> {
28 T::produce(parser, meta).map(Box::new)
29 }
30}