aboutsummaryrefslogtreecommitdiffstats
path: root/src/generics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/generics.rs')
-rw-r--r--src/generics.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/generics.rs b/src/generics.rs
index de0772a7..0950c1cb 100644
--- a/src/generics.rs
+++ b/src/generics.rs
@@ -172,17 +172,10 @@ impl Generics {
/// Initializes an empty `where`-clause if there is not one present already.
pub fn make_where_clause(&mut self) -> &mut WhereClause {
- // This is Option::get_or_insert_with in Rust 1.20.
- if self.where_clause.is_none() {
- self.where_clause = Some(WhereClause {
- where_token: <Token![where]>::default(),
- predicates: Punctuated::new(),
- });
- }
- match &mut self.where_clause {
- Some(where_clause) => where_clause,
- None => unreachable!(),
- }
+ self.where_clause.get_or_insert_with(|| WhereClause {
+ where_token: <Token![where]>::default(),
+ predicates: Punctuated::new(),
+ })
}
}