pub enum TypeName<'s> {
    None,
    Array(TypeNameArray<'s>),
    Never,
    Pointer(TypeNamePointer<'s>),
    Reference(TypeNameReference<'s>),
    Slice(TypeNameSlice<'s>),
    Struct(TypeNameStruct<'s>),
    Tuple(TypeNameTuple<'s>),
    Trait(TypeNameTrait<'s>),
    Unit,
}
Expand description

Organizes type name string into distinct parts.

Variants

None

Array(TypeNameArray<'s>)

Never

Pointer(TypeNamePointer<'s>)

Reference(TypeNameReference<'s>)

Slice(TypeNameSlice<'s>)

Struct(TypeNameStruct<'s>)

Tuple(TypeNameTuple<'s>)

Trait(TypeNameTrait<'s>)

Unit

Implementations

Constructs a new TypeName with the name of T.

This is equivalent to calling std::any::type_name::<T>().into()

Returns the type name string without any module paths.

This is equivalent to calling TypeName::as_str_mn(0, 0);

Returns the type name string with the given number of module segments.

If the left and right module segments overlap, the overlapping segments will only be printed printed once.

Parameters
  • m: Number of module segments to include, beginning from the left (most significant).
  • n: Number of module segments to include, beginning from the right (least significant).

Returns an object that implements fmt::Display for printing the type name without any module paths directly with format! and {}.

When using this type name in a format! or similar it is more efficient to use this display instead of first creating a string.

Example
use tynm::TypeName;

let tn = TypeName::new::<String>();

println!("{}", tn.as_display());

Returns an object that implements fmt::Display for printing the type name without any module paths directly with format! and {}.

When using this type name in a format! or similar it is more efficient to use this display instead of first creating a string.

If the left and right module segments overlap, the overlapping segments will only be printed once.

Parameters
  • buffer: Buffer to write to.
  • m: Number of module segments to include, beginning from the left (most significant).
  • n: Number of module segments to include, beginning from the right (least significant).
Example
use tynm::TypeName;

let tn = TypeName::new::<String>();

println!("{}", tn.as_display_mn(1, 2));

Writes the type name string to the given buffer.

If the left and right module segments overlap, the overlapping segments will only be printed once.

Parameters
  • buffer: Buffer to write to.
  • m: Number of module segments to include, beginning from the left (most significant).
  • n: Number of module segments to include, beginning from the right (least significant).

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.