1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (c) ZeroC, Inc.

use super::super::*;
use crate::slice_file::Span;

#[derive(Debug)]
pub struct Attribute {
    pub kind: Box<dyn AttributeKind>,
    pub span: Span,
}

impl Attribute {
    pub fn new(directive: String, args: Vec<String>, span: Span) -> Self {
        let kind = Box::new(attributes::Unparsed { directive, args });
        Self { kind, span }
    }

    pub fn downcast<T: AttributeKind + 'static>(&self) -> Option<&T> {
        self.kind.as_any().downcast_ref()
    }
}

implement_Element_for!(Attribute, "attribute");
implement_Symbol_for!(Attribute);