From c214778ee1a9addfb89bf39a0e3886d5aea185e5 Mon Sep 17 00:00:00 2001 From: Folyd Date: Tue, 13 Feb 2024 14:33:25 -0800 Subject: [PATCH] Support both legacy object search index and latest map search index --- extension/script/add-search-index.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extension/script/add-search-index.js b/extension/script/add-search-index.js index 455dd6ca..cb2b6c18 100644 --- a/extension/script/add-search-index.js +++ b/extension/script/add-search-index.js @@ -34,9 +34,17 @@ // Remove unnecessary std crate's search index, such as core, alloc, etc let searchIndex = Object.create(null) - STD_CRATES.forEach(crate => { - searchIndex[crate] = window.searchIndex[crate]; - }); + if (window.searchIndex instanceof Map) { + // [rustdoc] Use Map instead of Object for source files and search index #118910 + // https://github.com/rust-lang/rust/pull/118910 + STD_CRATES.forEach(crate => { + searchIndex[crate] = window.searchIndex.get(crate); + }); + } else { + STD_CRATES.forEach(crate => { + searchIndex[crate] = window.searchIndex[crate]; + }); + } window.postMessage({ direction: `rust-search-extension:std`, message: {