[][src]Enum ra_ap_hir_ty::TypeCtor

pub enum TypeCtor {
    Bool,
    Char,
    Int(IntTy),
    Float(FloatTy),
    Adt(AdtId),
    Str,
    Slice,
    Array,
    RawPtr(Mutability),
    Ref(Mutability),
    FnDef(CallableDefId),
    FnPtr {
        num_args: u16,
        is_varargs: bool,
    },
    Never,
    Tuple {
        cardinality: u16,
    },
    AssociatedType(TypeAliasId),
    OpaqueType(OpaqueTyId),
    Closure {
        def: DefWithBodyId,
        expr: ExprId,
    },
}

A type constructor or type name: this might be something like the primitive type bool, a struct like Vec, or things like function pointers or tuples.

Variants

Bool

The primitive boolean type. Written as bool.

Char

The primitive character type; holds a Unicode scalar value (a non-surrogate code point). Written as char.

Int(IntTy)

A primitive integer type. For example, i32.

Float(FloatTy)

A primitive floating-point type. For example, f64.

Adt(AdtId)

Structures, enumerations and unions.

Str

The pointee of a string slice. Written as str.

Slice

The pointee of an array slice. Written as [T].

Array

An array with the given length. Written as [T; n].

RawPtr(Mutability)

A raw pointer. Written as *mut T or *const T

A reference; a pointer with an associated lifetime. Written as &'a mut T or &'a T.

The anonymous type of a function declaration/definition. Each function has a unique type, which is output (for a function named foo returning an i32) as fn() -> i32 {foo}.

This includes tuple struct / enum variant constructors as well.

For example the type of bar here:

fn foo() -> i32 { 1 }
let bar = foo; // bar: fn() -> i32 {foo}
FnPtr

A pointer to a function. Written as fn() -> i32.

For example the type of bar here:

fn foo() -> i32 { 1 }
let bar: fn() -> i32 = foo;

Fields of FnPtr

num_args: u16is_varargs: bool
Never

The never type !.

Tuple

A tuple type. For example, (i32, bool).

Fields of Tuple

cardinality: u16
AssociatedType(TypeAliasId)

Represents an associated item like Iterator::Item. This is used when we have tried to normalize a projection like T::Item but couldn't find a better representation. In that case, we generate an application type like (Iterator::Item)<T>.

OpaqueType(OpaqueTyId)

This represents a placeholder for an opaque type in situations where we don't know the hidden type (i.e. currently almost always). This is analogous to the AssociatedType type constructor. As with that one, these are only produced by Chalk.

Closure

The type of a specific closure.

The closure signature is stored in a FnPtr type in the first type parameter.

Fields of Closure

def: DefWithBodyIdexpr: ExprId

Implementations

impl TypeCtor[src]

pub fn num_ty_params(self, db: &dyn HirDatabase) -> usize[src]

pub fn krate(self, db: &dyn HirDatabase) -> Option<CrateId>[src]

pub fn as_generic_def(self) -> Option<GenericDefId>[src]

Trait Implementations

impl Clone for TypeCtor[src]

impl Copy for TypeCtor[src]

impl Debug for TypeCtor[src]

impl Eq for TypeCtor[src]

impl Hash for TypeCtor[src]

impl PartialEq<TypeCtor> for TypeCtor[src]

impl StructuralEq for TypeCtor[src]

impl StructuralPartialEq for TypeCtor[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> Any for T where
    T: Any

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

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

impl<T> Cast for T[src]

impl<T> CloneAny for T where
    T: Clone + Any

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?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.