Make generate function assist generate a function as a constructor if the name of function is new

This commit is contained in:
morine0122 2024-04-17 20:39:41 +09:00
parent 7dad0a231e
commit ff2629d651
2 changed files with 270 additions and 26 deletions

View file

@ -1489,6 +1489,14 @@ impl Adt {
.map(|arena| arena.1.clone())
}
pub fn as_struct(&self) -> Option<Struct> {
if let Self::Struct(v) = self {
Some(*v)
} else {
None
}
}
pub fn as_enum(&self) -> Option<Enum> {
if let Self::Enum(v) = self {
Some(*v)