We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ab30b6a commit c2fb70bCopy full SHA for c2fb70b
src/librustc/middle/lang_items.rs
@@ -78,19 +78,12 @@ impl LanguageItems {
78
}
79
80
pub fn fn_trait_kind(&self, id: DefId) -> Option<ty::ClosureKind> {
81
- let def_id_kinds = [
82
- (self.fn_trait(), ty::ClosureKind::Fn),
83
- (self.fn_mut_trait(), ty::ClosureKind::FnMut),
84
- (self.fn_once_trait(), ty::ClosureKind::FnOnce),
85
- ];
86
-
87
- for &(opt_def_id, kind) in &def_id_kinds {
88
- if Some(id) == opt_def_id {
89
- return Some(kind);
90
- }
+ match Some(id) {
+ x if x == self.fn_trait() => Some(ty::ClosureKind::Fn),
+ x if x == self.fn_mut_trait() => Some(ty::ClosureKind::FnMut),
+ x if x == self.fn_once_trait() => Some(ty::ClosureKind::FnOnce),
+ _ => None
91
92
93
- None
94
95
96
$(
0 commit comments