use crate::SymbolKind;
pub trait SymbolKindBehavior {
fn is_in_symbol(&self) -> bool;
fn is_type(&self) -> bool;
fn is_callable(&self) -> bool;
fn is_value(&self) -> bool;
fn display_name(&self) -> &'static str;
fn is_any(&self) -> bool;
fn matches(&self, other: &SymbolKind) -> bool;
}
impl SymbolKindBehavior for SymbolKind {
fn is_in_symbol(&self) -> bool {
SymbolKind::is_in_symbol(self)
}
fn is_type(&self) -> bool {
SymbolKind::is_type(self)
}
fn is_callable(&self) -> bool {
SymbolKind::is_callable(self)
}
fn is_value(&self) -> bool {
SymbolKind::is_value(self)
}
fn display_name(&self) -> &'static str {
SymbolKind::display_name(self)
}
fn is_any(&self) -> bool {
SymbolKind::is_any(self)
}
fn matches(&self, other: &SymbolKind) -> bool {
SymbolKind::matches(self, other)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn trait_delegates_to_inherent_is_in_symbol() {
let v = SymbolKind::Variable;
assert_eq!(SymbolKindBehavior::is_in_symbol(&v), v.is_in_symbol());
}
#[test]
fn trait_delegates_to_inherent_display_name() {
let s = SymbolKind::Struct;
assert_eq!(SymbolKindBehavior::display_name(&s), s.display_name());
}
#[test]
fn trait_delegates_to_inherent_matches() {
let a = SymbolKind::Function;
let b = SymbolKind::Any;
assert_eq!(
SymbolKindBehavior::matches(&a, &b),
SymbolKind::matches(&a, &b)
);
}
}