Skip to content

Commit ff2629d

Browse files
committed
Make generate function assist generate a function as a constructor if the name of function is new
1 parent 7dad0a2 commit ff2629d

File tree

2 files changed

+270
-26
lines changed

2 files changed

+270
-26
lines changed

crates/hir/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,14 @@ impl Adt {
14891489
.map(|arena| arena.1.clone())
14901490
}
14911491

1492+
pub fn as_struct(&self) -> Option<Struct> {
1493+
if let Self::Struct(v) = self {
1494+
Some(*v)
1495+
} else {
1496+
None
1497+
}
1498+
}
1499+
14921500
pub fn as_enum(&self) -> Option<Enum> {
14931501
if let Self::Enum(v) = self {
14941502
Some(*v)

0 commit comments

Comments
 (0)