Skip to main content

Name

Enum Name 

Source
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.

Fields

§value: &'src str
§span: Span
§

Complex

Multi-part or prefixed name (Foo\Bar, \Foo, namespace\Foo).

Fields

§parts: ArenaVec<'arena, &'src str>
§span: Span

Implementations§

Source§

impl<'arena, 'src> Name<'arena, 'src>

Source

pub fn span(&self) -> Span

Source

pub fn kind(&self) -> NameKind

Source

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).

Source

pub fn join_parts(&self) -> Cow<'src, str>

Joins all parts with \ without any leading backslash. Returns Cow::Borrowed for simple names (zero allocation).

Source

pub fn parts_slice(&self) -> &[&'src str]

Returns the parts as a slice. For Simple, returns a single-element slice of the value.

Trait Implementations§

Source§

impl<'arena, 'src> Debug for Name<'arena, 'src>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'arena, 'src> Serialize for Name<'arena, 'src>

Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'arena, 'src> Freeze for Name<'arena, 'src>

§

impl<'arena, 'src> !RefUnwindSafe for Name<'arena, 'src>

§

impl<'arena, 'src> !Send for Name<'arena, 'src>

§

impl<'arena, 'src> !Sync for Name<'arena, 'src>

§

impl<'arena, 'src> Unpin for Name<'arena, 'src>

§

impl<'arena, 'src> UnsafeUnpin for Name<'arena, 'src>

§

impl<'arena, 'src> !UnwindSafe for Name<'arena, 'src>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.