diff options
| author | Colin Wallace <colin@mooooo.ooo> | 2018-07-23 22:06:45 -0700 |
|---|---|---|
| committer | Colin Wallace <colin@mooooo.ooo> | 2018-07-23 22:06:45 -0700 |
| commit | cbe5f1c4207673b9059e832ef2f134b4f87b380d (patch) | |
| tree | 3a076c3045a44ceeae9c8add4e05416d562d4747 /src/libsyntax_ext | |
| parent | 10d82137b3fe45a3b0f0c1bd9080ee46b5259ac1 (diff) | |
| download | rust-cbe5f1c4207673b9059e832ef2f134b4f87b380d.tar.gz rust-cbe5f1c4207673b9059e832ef2f134b4f87b380d.zip | |
libsyntax_ext: Prefer `Option::map` over `match` where applicable
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/deriving/generic/ty.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index dcccb187bef..a0845e0982d 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -138,17 +138,13 @@ pub fn nil_ty<'r>() -> Ty<'r> { } fn mk_lifetime(cx: &ExtCtxt, span: Span, lt: &Option<&str>) -> Option<ast::Lifetime> { - match *lt { - Some(s) => Some(cx.lifetime(span, Ident::from_str(s))), - None => None, - } + lt.map(|s| + cx.lifetime(span, Ident::from_str(s)) + ) } fn mk_lifetimes(cx: &ExtCtxt, span: Span, lt: &Option<&str>) -> Vec<ast::Lifetime> { - match *lt { - Some(s) => vec![cx.lifetime(span, Ident::from_str(s))], - None => vec![], - } + mk_lifetime(cx, span, lt).into_iter().collect() } impl<'a> Ty<'a> { |
