1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use serde::Serialize;
use crate::{diagnostic::Diagnostic, span::Span};
#[derive(Debug, PartialEq, Serialize)]
#[serde(transparent)]
pub struct CustomTag<'a> {
pub name: Span<'a>,
#[serde(skip)]
pub source: Span<'a>,
}
impl<'a> CustomTag<'a> {
pub fn parse(name: Span<'a>) -> Result<Self, Diagnostic> {
Ok(Self { name, source: name })
}
}
#[cfg(test)]
mod tests {
use insta::assert_yaml_snapshot;
use super::*;
#[test]
fn custom_tag() {
let source = Span::dummy("example");
let value = CustomTag::parse(source).unwrap();
assert_yaml_snapshot!(value, @r###"
---
example
"###);
}
}