[][src]Enum tynm::TypeName

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

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

Methods

impl<'s> TypeName<'s>[src]

pub fn new<T>() -> Self[src]

Constructs a new TypeName with the name of T.

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

pub fn as_str(&self) -> String[src]

Returns the type name string without any module paths.

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

pub fn as_str_mn(&self, m: usize, n: usize) -> String[src]

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

pub fn as_display(&self) -> TypeNameDisplay[src]

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());

pub fn as_display_mn(&self, m: usize, n: usize) -> TypeNameDisplay[src]

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

pub fn write_str<W>(
    &self,
    buffer: &mut W,
    m: usize,
    n: usize
) -> Result<(), Error> where
    W: Write
[src]

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

impl<'s> Clone for TypeName<'s>[src]

impl<'s> Debug for TypeName<'s>[src]

impl<'s> Eq for TypeName<'s>[src]

impl<'s> From<&'s str> for TypeName<'s>[src]

impl<'s> PartialEq<TypeName<'s>> for TypeName<'s>[src]

impl<'s> StructuralEq for TypeName<'s>[src]

impl<'s> StructuralPartialEq for TypeName<'s>[src]

Auto Trait Implementations

impl<'s> RefUnwindSafe for TypeName<'s>

impl<'s> Send for TypeName<'s>

impl<'s> Sync for TypeName<'s>

impl<'s> Unpin for TypeName<'s>

impl<'s> UnwindSafe for TypeName<'s>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.