diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5329b4d7..08bd9089 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - vim-version: [v7.4.2119, v8.2.5172, head] + vim-version: [v7.4.2119, v8.2.5172, v9.0.1500] runs-on: ${{ matrix.os }} steps: - name: Checkout kkoomen/vim-doge diff --git a/helper/src/rust/parser.rs b/helper/src/rust/parser.rs index 63cbbfcb..20d604a8 100644 --- a/helper/src/rust/parser.rs +++ b/helper/src/rust/parser.rs @@ -100,15 +100,19 @@ impl<'a> RustParser<'a> { .for_each(|node| { let mut param = Map::new(); - let func_name = node + let name = node .children(&mut node.walk()) .filter(|node| node.kind() == "identifier") .next() - .and_then(|node| Some(self.get_node_text(&node))) - .unwrap(); - param.insert("name".to_string(), Value::String(func_name)); + .and_then(|node| Some(self.get_node_text(&node))); - params.push(Value::Object(param)); + if name.is_some() { + param.insert("name".to_string(), Value::String(name.unwrap())); + } + + if !param.is_empty() { + params.push(Value::Object(param)); + } }); if !params.is_empty() { diff --git a/test/filetypes/rust/functions.vader b/test/filetypes/rust/functions.vader index 7539300e..a151808c 100644 --- a/test/filetypes/rust/functions.vader +++ b/test/filetypes/rust/functions.vader @@ -59,6 +59,29 @@ Expect rust (generated comments with Arguments and Examples sections): } } +# ============================================================================== +# Functions parameter destruction +# ============================================================================== +Given rust (function with destructured params): + pub fn do_thing((i, j): (u8, u8)) -> u8 { + i * j + } + +Do (trigger doge): + \ + +Expect rust (generated comments): + /// [TODO:description] + /// + /// # Examples + /// + /// ``` + /// [TODO:write some example code] + /// ``` + pub fn do_thing((i, j): (u8, u8)) -> u8 { + i * j + } + # ============================================================================== # Functions with errors and safety section # ==============================================================================