Skip to content

Commit cbe5f1c

Browse files
committed
libsyntax_ext: Prefer Option::map over match where applicable
1 parent 10d8213 commit cbe5f1c

File tree

1 file changed

+4
-8
lines changed
  • src/libsyntax_ext/deriving/generic

1 file changed

+4
-8
lines changed

src/libsyntax_ext/deriving/generic/ty.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,13 @@ pub fn nil_ty<'r>() -> Ty<'r> {
138138
}
139139

140140
fn mk_lifetime(cx: &ExtCtxt, span: Span, lt: &Option<&str>) -> Option<ast::Lifetime> {
141-
match *lt {
142-
Some(s) => Some(cx.lifetime(span, Ident::from_str(s))),
143-
None => None,
144-
}
141+
lt.map(|s|
142+
cx.lifetime(span, Ident::from_str(s))
143+
)
145144
}
146145

147146
fn mk_lifetimes(cx: &ExtCtxt, span: Span, lt: &Option<&str>) -> Vec<ast::Lifetime> {
148-
match *lt {
149-
Some(s) => vec![cx.lifetime(span, Ident::from_str(s))],
150-
None => vec![],
151-
}
147+
mk_lifetime(cx, span, lt).into_iter().collect()
152148
}
153149

154150
impl<'a> Ty<'a> {

0 commit comments

Comments
 (0)