pub fn read_discriminant_as_variant_index(
        &self,
        rval: OpTy<'tcx>,
    ) -> EvalResult<'tcx, usize> {
        match rval.layout.variants {
            layout::Variants::Single { index } => Ok(index),
            layout::Variants::Tagged { .. } => {
                let discr_val = self.read_discriminant_value(rval)?;
                rval.layout.ty
                    .ty_adt_def()
                    .expect("tagged layout for non adt")
                    .discriminants(self.tcx.tcx)
                    .position(|var| var.val == discr_val)
                    .ok_or_else(|| EvalErrorKind::InvalidDiscriminant.into())
            }
            layout::Variants::NicheFilling { .. } => {
                let discr_val = self.read_discriminant_value(rval)?;
                assert_eq!(discr_val as usize as u128, discr_val);
                Ok(discr_val as usize)
            },
        }
    }
/// reads a tag and produces the corresponding variant index
reads a tag and produces the corresponding variant index
reads a tag and produces the corresponding variant index
pub fn read_discriminant_as_variant_index(
        &self,
        rval: OpTy<'tcx>,
    ) -> EvalResult<'tcx, usize> {
        match rval.layout.variants {
            layout::Variants::Single { index } => Ok(index),
            layout::Variants::Tagged { .. } => {
                let discr_val = self.read_discriminant_value(rval)?;
                rval.layout.ty
                    .ty_adt_def()
                    .expect("tagged layout for non adt")
                    .discriminants(self.tcx.tcx)
                    .position(|var| var.val == discr_val)
                    .ok_or_else(|| EvalErrorKind::InvalidDiscriminant.into())
            }
            layout::Variants::NicheFilling { .. } => {
                let discr_val = self.read_discriminant_value(rval)?;
                assert_eq!(discr_val as usize as u128, discr_val);
                Ok(discr_val as usize)
            },
        }
    }
pub fn read_discriminant_as_variant_index ( & self , rval : OpTy < ' tcx > , ) -> EvalResult < ' tcx , usize > { match rval . layout . variants { layout :: Variants :: Single { index } => Ok ( index ) , layout :: Variants :: Tagged { .. } => { let discr_val = self . read_discriminant_value ( rval ) ? ; rval . layout . ty . ty_adt_def ( ) . expect ( " " ) . discriminants ( self . tcx . tcx ) . position ( | var | var . val == discr_val ) . ok_or_else ( | | EvalErrorKind :: InvalidDiscriminant . into ( ) ) } layout :: Variants :: NicheFilling { .. } => { let discr_val = self . read_discriminant_value ( rval ) ? ; assert_eq ! ( discr_val as usize as u128 discr_val ) ; Ok ( discr_val as usize ) } , } }
reads a tag and produces the corresponding variant index
reads a tag and produces the corresponding variant index
&self
rval
OpTy<'tcx>