slicec/grammar/elements/
attribute.rs1use super::super::*;
4use crate::slice_file::Span;
5
6#[derive(Debug)]
7pub struct Attribute {
8 pub kind: Box<dyn AttributeKind>,
9 pub span: Span,
10}
11
12impl Attribute {
13 pub fn new(directive: String, args: Vec<String>, span: Span) -> Self {
14 let kind = Box::new(attributes::Unparsed { directive, args });
15 Self { kind, span }
16 }
17
18 pub fn downcast<T: AttributeKind + 'static>(&self) -> Option<&T> {
19 self.kind.as_any().downcast_ref()
20 }
21}
22
23implement_Element_for!(Attribute, "attribute");
24implement_Symbol_for!(Attribute);