y_lang/ast/
type_annotation.rs1use pest::iterators::Pair;
2
3use super::{Position, Rule, Type};
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
6pub struct TypeAnnotation {
7 pub value: Type,
8 pub position: Position,
9}
10
11impl TypeAnnotation {
12 pub fn from_pair(pair: Pair<Rule>, file: &str) -> TypeAnnotation {
13 let (line, col) = pair.line_col();
14
15 let mut inner = pair.into_inner();
16
17 TypeAnnotation {
18 value: Type::from_pair(inner.next().unwrap()),
19 position: (file.to_owned(), line, col),
20 }
21 }
22}