pub enum Name<'arena, 'src> {
Simple {
value: &'src str,
span: Span,
},
Complex {
parts: ArenaVec<'arena, &'src str>,
kind: NameKind,
span: Span,
},
}Expand description
A PHP name (identifier, qualified name, fully-qualified name, or relative name).
The Simple variant is the fast path for the common case (~95%) of single
unqualified identifiers like strlen, Foo, MyClass. It avoids allocating
an ArenaVec entirely.
The Complex variant handles qualified (Foo\Bar), fully-qualified (\Foo\Bar),
and relative (namespace\Foo) names.
Variants§
Simple
Single unqualified identifier — no ArenaVec allocation.
&'src str instead of Cow since this is always a borrowed slice of the source.
Complex
Multi-part or prefixed name (Foo\Bar, \Foo, namespace\Foo).
Implementations§
Source§impl<'arena, 'src> Name<'arena, 'src>
impl<'arena, 'src> Name<'arena, 'src>
pub fn span(&self) -> Span
pub fn kind(&self) -> NameKind
Sourcepub fn to_string_repr(&self) -> Cow<'src, str>
pub fn to_string_repr(&self) -> Cow<'src, str>
Joins all parts with \ and prepends \ if fully qualified.
Returns Cow::Borrowed for simple names (zero allocation).
Sourcepub fn join_parts(&self) -> Cow<'src, str>
pub fn join_parts(&self) -> Cow<'src, str>
Joins all parts with \ without any leading backslash.
Returns Cow::Borrowed for simple names (zero allocation).
Sourcepub fn parts_slice(&self) -> &[&'src str]
pub fn parts_slice(&self) -> &[&'src str]
Returns the parts as a slice.
For Simple, returns a single-element slice of the value.