rustdoc-search: simplify JS in checkGenerics

This commit is contained in:
Michael Howell 2023-06-02 18:31:51 -07:00
parent 37998ab508
commit 04f4493722

View File

@ -1179,7 +1179,7 @@ function initSearch(rawSearchIndex) {
/**
* This function checks if the object (`row`) generics match the given type (`elem`)
* generics. If there are no generics on `row`, `defaultDistance` is returned.
* generics.
*
* @param {Row} row - The object to check.
* @param {QueryElement} elem - The element from the parsed query.
@ -1196,7 +1196,9 @@ function initSearch(rawSearchIndex) {
// This search engine implements order-agnostic unification. There
// should be no missing duplicates (generics have "bag semantics"),
// and the row is allowed to have extras.
if (elem.generics.length > 0 && row.generics.length >= elem.generics.length) {
if (elem.generics.length <= 0 || row.generics.length < elem.generics.length) {
return false;
}
const elems = new Map();
const addEntryToElems = function addEntryToElems(entry) {
if (entry.id === -1) {
@ -1271,8 +1273,6 @@ function initSearch(rawSearchIndex) {
}
return true;
}
return false;
}
/**
* This function checks if the object (`row`) matches the given type (`elem`) and its