codama_koroks/
unsupported_impl_item_korok.rs1use crate::KorokTrait;
2use codama_attributes::Attributes;
3use codama_errors::CodamaResult;
4use codama_nodes::Node;
5
6#[derive(Debug, PartialEq)]
7pub struct UnsupportedImplItemKorok<'a> {
8 pub ast: &'a syn::ImplItem,
9 pub attributes: Attributes<'a>,
10 pub node: Option<Node>,
11}
12
13impl<'a> UnsupportedImplItemKorok<'a> {
14 pub fn parse(ast: &'a syn::ImplItem) -> CodamaResult<Self> {
15 let attributes = match ast {
16 syn::ImplItem::Const(item) => Attributes::parse(&item.attrs, ast.into())?,
17 syn::ImplItem::Fn(item) => Attributes::parse(&item.attrs, ast.into())?,
18 syn::ImplItem::Type(item) => Attributes::parse(&item.attrs, ast.into())?,
19 syn::ImplItem::Macro(item) => Attributes::parse(&item.attrs, ast.into())?,
20 _ => Attributes(Vec::new()),
21 };
22 Ok(Self {
23 ast,
24 attributes,
25 node: None,
26 })
27 }
28}
29
30impl KorokTrait for UnsupportedImplItemKorok<'_> {
31 fn node(&self) -> &Option<Node> {
32 &self.node
33 }
34
35 fn set_node(&mut self, node: Option<Node>) {
36 self.node = node;
37 }
38
39 fn attributes(&self) -> Option<&Attributes<'_>> {
40 Some(&self.attributes)
41 }
42}