Enum rustc::middle::traits::VtableUnstable [-] [+] [src]

pub enum Vtable<'tcx, N> {
    // some variants omitted
}

Given the successful resolution of an obligation, the Vtable indicates where the vtable comes from. Note that while we call this a "vtable", it does not necessarily indicate dynamic dispatch at runtime. Vtable instances just tell the compiler where to find methods, but in generic code those methods are typically statically dispatched -- only when an object is constructed is a Vtable instance reified into an actual vtable.

For example, the vtable may be tied to a specific impl (case A), or it may be relative to some bound that is in scope (case B).

impl<T:Clone> Clone<T> for Option<T> { ... } // Impl_1
impl<T:Clone> Clone<T> for Box<T> { ... }    // Impl_2
impl Clone for int { ... }             // Impl_3

fn foo<T:Clone>(concrete: Option<Box<int>>,
                param: T,
                mixed: Option<T>) {

   // Case A: Vtable points at a specific impl. Only possible when
   // type is concretely known. If the impl itself has bounded
   // type parameters, Vtable will carry resolutions for those as well:
   concrete.clone(); // Vtable(Impl_1, [Vtable(Impl_2, [Vtable(Impl_3)])])

   // Case B: Vtable must be provided by caller. This applies when
   // type is a type parameter.
   param.clone();    // VtableParam

   // Case C: A mix of cases A and B.
   mixed.clone();    // Vtable(Impl_1, [VtableParam])
}

The type parameter N

See explanation on VtableImplData.

Methods

impl<'tcx, N> Vtable<'tcx, N>

fn iter_nested(&self) -> Iter<N>

fn map_nested<M, F>(&self, op: F) -> Vtable<'tcx, M> where F: FnMut(&N) -> M

fn map_move_nested<M, F>(self, op: F) -> Vtable<'tcx, M> where F: FnMut(N) -> M

Trait Implementations

impl<'tcx, N: Repr<'tcx>> Repr<'tcx> for Vtable<'tcx, N>

fn repr(&self, tcx: &ctxt<'tcx>) -> String

impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vtable<'tcx, N>

fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Vtable<'tcx, N>

Derived Implementations

impl<'tcx, N: Clone> Clone for Vtable<'tcx, N> where N: Clone, N: Clone, N: Clone, N: Clone

fn clone(&self) -> Vtable<'tcx, N>

fn clone_from(&mut self, source: &Self)

impl<'tcx, N: Debug> Debug for Vtable<'tcx, N> where N: Debug, N: Debug, N: Debug, N: Debug

fn fmt(&self, __arg_0: &mut Formatter) -> Result