use crate::ast::AstPath;
use super::CommonItemData;
#[repr(C)]
#[derive(Debug)]
pub struct UseItem<'ast> {
data: CommonItemData<'ast>,
use_path: AstPath<'ast>,
use_kind: UseKind,
}
super::impl_item_data!(UseItem, Use);
#[repr(C)]
#[non_exhaustive]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "driver-api", visibility::make(pub))]
pub(crate) enum UseKind {
Single,
Glob,
}
impl<'ast> UseItem<'ast> {
pub fn use_path(&self) -> &AstPath<'ast> {
&self.use_path
}
pub fn is_glob(&self) -> bool {
matches!(self.use_kind, UseKind::Glob)
}
}
#[cfg(feature = "driver-api")]
impl<'ast> UseItem<'ast> {
pub fn new(data: CommonItemData<'ast>, use_path: AstPath<'ast>, use_kind: UseKind) -> Self {
Self {
data,
use_path,
use_kind,
}
}
}