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.
This commit is contained in:
@@ -1969,6 +1969,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