ryo-symbol 0.2.0

Symbol system for Rust codebase - unique identifiers and file path management
Documentation
//! SKETCH (Journal 2026-06-06 訂正章 next pickup #1): CrossCrateExtractTrait
//! 1 件 hand-craft evaluation on `SymbolKind`.
//!
//! Goal: empirically check whether extracting a behavior trait from the
//! `<impl SymbolKind>` inherent block (= r15_only_skip candidate #3,
//! methods=7) yields any architectural surface improvement that justifies
//! the `CrossCrateExtractTrait` epic. Single concrete impl; no caller
//! migration here — caller-side evaluation happens after this compiles.
//!
//! This file is module-private (no `pub use` from lib.rs); deleting one
//! `mod` line in lib.rs removes it cleanly.
//!
//! Status: sketch only, not consumed by any caller. Do NOT remove without
//! updating Journal 2026-06-06 訂正章 #1 evaluation column.

use crate::SymbolKind;

/// Behavior trait extracted from the 7 inherent methods of `SymbolKind`.
///
/// Each method delegates verbatim to the inherent impl in `kind.rs` —
/// no semantic change, no new behavior. The point of this sketch is to
/// see whether the trait extraction reveals any reusable abstraction
/// across other types (it does not: see Journal evaluation).
pub trait SymbolKindBehavior {
    /// Check if this is an InSymbol kind (variable, parameter, or field).
    fn is_in_symbol(&self) -> bool;
    /// Check if this is a type definition.
    fn is_type(&self) -> bool;
    /// Check if this is callable.
    fn is_callable(&self) -> bool;
    /// Check if this is a value.
    fn is_value(&self) -> bool;
    /// Get display name.
    fn display_name(&self) -> &'static str;
    /// Check if this is a wildcard.
    fn is_any(&self) -> bool;
    /// Returns true if this matches the given kind.
    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)
        );
    }
}