From 0233abebc85d336e92849ae7bca1fd8c1ef4f097 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 24 Apr 2022 15:36:34 +0200 Subject: [PATCH] Update rustdoc-js tester tool to work with new kind of variables --- src/tools/rustdoc-js/tester.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 17362338355..98d0f5dc656 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -85,8 +85,11 @@ function extractFunction(content, functionName) { } // Stupid function extractor for array. -function extractArrayVariable(content, arrayName) { - var splitter = "var " + arrayName; +function extractArrayVariable(content, arrayName, kind) { + if (typeof kind === "undefined") { + kind = "let "; + } + var splitter = kind + arrayName; while (true) { var start = content.indexOf(splitter); if (start === -1) { @@ -126,12 +129,18 @@ function extractArrayVariable(content, arrayName) { } content = content.slice(start + 1); } + if (kind === "let ") { + return extractArrayVariable(content, arrayName, "const "); + } return null; } // Stupid function extractor for variable. -function extractVariable(content, varName) { - var splitter = "var " + varName; +function extractVariable(content, varName, kind) { + if (typeof kind === "undefined") { + kind = "let "; + } + var splitter = kind + varName; while (true) { var start = content.indexOf(splitter); if (start === -1) { @@ -162,6 +171,9 @@ function extractVariable(content, varName) { } content = content.slice(start + 1); } + if (kind === "let ") { + return extractVariable(content, varName, "const "); + } return null; }