]> git.lizzy.rs Git - rust.git/commitdiff
minor: improve readability
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 19 Sep 2021 08:34:25 +0000 (11:34 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 19 Sep 2021 08:34:25 +0000 (11:34 +0300)
crates/parser/src/grammar/generic_args.rs

index 9f6f74c669712afa49adf867de6d12bc79e5ffca..3b9444a6ff2b8e4fd1ddb94f79c43cee283b0524 100644 (file)
@@ -27,11 +27,7 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) {
 // type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;
 fn generic_arg(p: &mut Parser) {
     match p.current() {
-        LIFETIME_IDENT => {
-            let m = p.start();
-            lifetime(p);
-            m.complete(p, LIFETIME_ARG);
-        }
+        LIFETIME_IDENT => lifetime_arg(p),
         // test associated_type_bounds
         // fn print_all<T: Iterator<Item, Item::Item, Item::<true>, Item: Display, Item<'a> = Item>>(printables: T) {}
         IDENT if [T![<], T![=], T![:]].contains(&p.nth(1)) => {
@@ -83,14 +79,16 @@ fn generic_arg(p: &mut Parser) {
         // fn f() { S::<-1> }
         T!['{'] | T![true] | T![false] | T![-] => const_arg(p),
         k if k.is_literal() => const_arg(p),
-        _ => {
-            let m = p.start();
-            types::type_(p);
-            m.complete(p, TYPE_ARG);
-        }
+        _ => type_arg(p),
     }
 }
 
+fn lifetime_arg(p: &mut Parser) {
+    let m = p.start();
+    lifetime(p);
+    m.complete(p, LIFETIME_ARG);
+}
+
 pub(super) fn const_arg(p: &mut Parser) {
     let m = p.start();
     match p.current() {
@@ -121,3 +119,9 @@ pub(super) fn const_arg(p: &mut Parser) {
         }
     }
 }
+
+fn type_arg(p: &mut Parser) {
+    let m = p.start();
+    types::type_(p);
+    m.complete(p, TYPE_ARG);
+}