pub fn struct_tail_with_normalize(self,
                                      mut ty: Ty<'tcx>,
                                      normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>)
                                      -> Ty<'tcx>
    {
        loop {
            match ty.kind {
                ty::Adt(def, substs) => {
                    if !def.is_struct() {
                        break;
                    }
                    match def.non_enum_variant().fields.last() {
                        Some(f) => ty = f.ty(self, substs),
                        None => break,
                    }
                }

                ty::Tuple(tys) => {
                    if let Some((&last_ty, _)) = tys.split_last() {
                        ty = last_ty.expect_ty();
                    } else {
                        break;
                    }
                }

                ty::Projection(_) | ty::Opaque(..) => {
                    let normalized = normalize(ty);
                    if ty == normalized {
                        return ty;
                    } else {
                        ty = normalized;
                    }
                }

                _ => {
                    break;
                }
            }
        }
        ty
    }
/// Returns the deeply last field of nested structures, or the same type if
/// not a structure at all. Corresponds to the only possible unsized field,
/// and its type can be used to determine unsizing strategy.
///
/// This is parameterized over the normalization strategy (i.e. how to
/// handle `<T as Trait>::Assoc` and `impl Trait`); pass the identity
/// function to indicate no normalization should take place.
///
/// See also `struct_tail_erasing_lifetimes`, which is suitable for use
/// during codegen.
Returns the deeply last field of nested structures, or the same type if
not a structure at all. Corresponds to the only possible unsized field,
and its type can be used to determine unsizing strategy.

This is parameterized over the normalization strategy ; pass the identity
function to indicate no normalization should take place.

See also `struct_tail_erasing_lifetimes`, which is suitable for use
during codegen.
Returns the deeply last field of nested structures or the same type if not a structure at all . Corresponds to the only possible unsized field and its type can be used to determine unsizing strategy . This is parameterized over the normalization strategy ; pass the identity function to indicate no normalization should take place . See also ` struct_tail_erasing_lifetimes ` which is suitable for use during codegen .
pub fn struct_tail_with_normalize(self,
                                      mut ty: Ty<'tcx>,
                                      normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>)
                                      -> Ty<'tcx>
    {
        loop {
            match ty.kind {
                ty::Adt(def, substs) => {
                    if !def.is_struct() {
                        break;
                    }
                    match def.non_enum_variant().fields.last() {
                        Some(f) => ty = f.ty(self, substs),
                        None => break,
                    }
                }
                ty::Tuple(tys) => {
                    if let Some((&last_ty, _)) = tys.split_last() {
                        ty = last_ty.expect_ty();
                    } else {
                        break;
                    }
                }
                ty::Projection(_) | ty::Opaque(..) => {
                    let normalized = normalize(ty);
                    if ty == normalized {
                        return ty;
                    } else {
                        ty = normalized;
                    }
                }
                _ => {
                    break;
                }
            }
        }
        ty
    }
pub fn struct_tail_with_normalize ( self , mut ty : Ty < ' tcx > , normalize : impl Fn ( Ty < ' tcx > ) -> Ty < ' tcx > ) -> Ty < ' tcx > { loop { match ty . kind { ty :: Adt ( def , substs ) => { if ! def . is_struct ( ) { break ; } match def . non_enum_variant ( ) . fields . last ( ) { Some ( f ) => ty = f . ty ( self , substs ) , None => break , } } ty :: Tuple ( tys ) => { if let Some ( ( & last_ty , _ ) ) = tys . split_last ( ) { ty = last_ty . expect_ty ( ) ; } else { break ; } } ty :: Projection ( _ ) | ty :: Opaque ( .. ) => { let normalized = normalize ( ty ) ; if ty == normalized { return ty ; } else { ty = normalized ; } } _ => { break ; } } } ty }
Returns the deeply last field of nested structures, or the same type if
not a structure at all.
Returns the deeply last field of nested structures or the same type if not a structure at all .
self
ty
Ty<'tcx>
normalize
impl Fn(Ty<'tcx>) -> Ty<'tcx>