Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/traits.rs')
| -rw-r--r-- | crates/hir-ty/src/traits.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/hir-ty/src/traits.rs b/crates/hir-ty/src/traits.rs index b2232b920a..8b692a1cc1 100644 --- a/crates/hir-ty/src/traits.rs +++ b/crates/hir-ty/src/traits.rs @@ -217,6 +217,15 @@ impl FnTrait { } } + pub const fn from_lang_item(lang_item: LangItem) -> Option<Self> { + match lang_item { + LangItem::FnOnce => Some(FnTrait::FnOnce), + LangItem::FnMut => Some(FnTrait::FnMut), + LangItem::Fn => Some(FnTrait::Fn), + _ => None, + } + } + pub const fn to_chalk_ir(self) -> rust_ir::ClosureKind { match self { FnTrait::FnOnce => rust_ir::ClosureKind::FnOnce, |