catchr_core/
section_item.rs1use crate::catchr_mode::CatchrMode;
2use crate::section::Section;
3
4#[allow(clippy::large_enum_variant)]
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub enum SectionItem {
7 Sep(Section),
8 Stmt(syn::Stmt),
9}
10
11impl SectionItem {
12 pub fn with_mode(self, test_attribute: CatchrMode) -> Self {
13 match self {
14 SectionItem::Sep(section) => {
15 SectionItem::Sep(section.with_mode(test_attribute))
16 }
17 stmt => stmt,
18 }
19 }
20
21 pub fn is_stmt(&self) -> bool {
22 matches!(self, Self::Stmt(_))
23 }
24
25 pub fn stmt(&self) -> Option<syn::Stmt> {
26 match self {
27 Self::Stmt(inner) => Some(inner.clone()),
28 _ => None,
29 }
30 }
31}