Skip to content

Commit c2fb70b

Browse files
committed
Refactor fn_trait_kind
Short and sweet
1 parent ab30b6a commit c2fb70b

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/librustc/middle/lang_items.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,12 @@ impl LanguageItems {
7878
}
7979

8080
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-
}
81+
match Some(id) {
82+
x if x == self.fn_trait() => Some(ty::ClosureKind::Fn),
83+
x if x == self.fn_mut_trait() => Some(ty::ClosureKind::FnMut),
84+
x if x == self.fn_once_trait() => Some(ty::ClosureKind::FnOnce),
85+
_ => None
9186
}
92-
93-
None
9487
}
9588

9689
$(

0 commit comments

Comments
 (0)