Rollup merge of #110394 - scottmcm:less-idx-new, r=WaffleLapkin
Various minor Idx-related tweaks Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify. cc https://github.com/rust-lang/compiler-team/issues/606 r? `@WaffleLapkin`
This commit is contained in:
@@ -1963,6 +1963,16 @@ impl VariantDef {
|
||||
pub fn ctor_def_id(&self) -> Option<DefId> {
|
||||
self.ctor.map(|(_, def_id)| def_id)
|
||||
}
|
||||
|
||||
/// Returns the one field in this variant.
|
||||
///
|
||||
/// `panic!`s if there are no fields or multiple fields.
|
||||
#[inline]
|
||||
pub fn single_field(&self) -> &FieldDef {
|
||||
assert!(self.fields.len() == 1);
|
||||
|
||||
&self.fields[FieldIdx::from_u32(0)]
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for VariantDef {
|
||||
|
||||
Reference in New Issue
Block a user