"use strict";if(!Array.prototype.toSpliced){Array.prototype.toSpliced=function(){constme=this.slice();Array.prototype.splice.apply(me,arguments);returnme}}(function(){constitemTypes=["keyword","primitive","mod","externcrate","import","struct","enum","fn","type","static","trait","impl","tymethod","method","structfield","variant","macro","associatedtype","constant","associatedconstant","union","foreigntype","existential","attr","derive","traitalias","generic",];constlongItemTypes=["keyword","primitive type","module","extern crate","re-export","struct","enum","function","type alias","static","trait","","trait method","method","struct field","enum variant","macro","assoc type","constant","assoc const","union","foreign type","existential type","attribute macro","derive macro","trait alias",];constTY_GENERIC=itemTypes.indexOf("generic");constROOT_PATH=typeofwindow!=="undefined"?window.rootPath:"../";functionprintTab(nb){letiter=0;letfoundCurrentTab=false;letfoundCurrentResultSet=false;onEachLazy(document.getElementById("search-tabs").childNodes,elem=>{if(nb===iter){addClass(elem,"selected");foundCurrentTab=true}else{removeClass(elem,"selected")}iter+=1});constisTypeSearch=(nb>0||iter===1);iter=0;onEachLazy(document.getElementById("results").childNodes,elem=>{if(nb===iter){addClass(elem,"active");foundCurrentResultSet=true}else{removeClass(elem,"active")}iter+=1});if(foundCurrentTab&&foundCurrentResultSet){searchState.currentTab=nb;constcorrectionsElem=document.getElementsByClassName("search-corrections");if(isTypeSearch){removeClass(correctionsElem[0],"hidden")}else{addClass(correctionsElem[0],"hidden")}}elseif(nb!==0){printTab(0)}}consteditDistanceState={current:[],prev:[],prevPrev:[],calculate:functioncalculate(a,b,limit){if(a.length<b.length){constaTmp=a;a=b;b=aTmp}constminDist=a.length-b.length;if(minDist>limit){returnlimit+1}while(b.length>0&&b[0]===a[0]){a=a.substring(1);b=b.substring(1)}while(b.length>0&&b[b.length-1]===a[a.length-1]){a=a.substring(0,a.length-1);b=b.substring(0,b.length-1)}if(b.length===0){returnminDist}constaLength=a.length;constbLength=b.length;for(leti=0;i<=bLength;++i){this.current[i]=0;this.prev[i]=i;this.prevPrev[i]=Number.MAX_VALUE}for(leti=1;i<=aLength;++i){this.current[0]=i;constaIdx=i-1;for(letj=1;j<=bLength;++j){constbIdx=j-1;constsubstitutionCost=a[aIdx]===b[bIdx]?0:1;this.current[j]=Math.min(this.prev[j]+1,this.current[j-1]+1,this.prev[j-1]+substitutionCost);if((i>1)&&(j>1)&&(a[aIdx]===b[bIdx-1])&&(a[aIdx-1]===b[bIdx])){this.current[j]=Math.min(this.current[j],this.prevPrev[j-2]+1)}}constprevPrevTmp=this.prevPrev;this.prevPrev=this.prev;this.prev=this.current;this.current=prevPrevTmp}constdistance=this.prev[bLength];returndistance<=limit?distance:(limit+1)},};functioneditDistance(a,b,limit){returneditDistanceState.calculate(a,b,limit)}functioninitSearch(rawSearchIndex){constMAX_RESULTS=200;constNO_TYPE_FILTER=-1;letsearchIndex;letfunctionTypeFingerprint;letcurrentResults;lettypeNameIdMap;constALIASES=newMap();lettypeNameIdOfArray;lettypeNameIdOfSlice;lettypeNameIdOfArrayOrSlice;lettypeNameIdOfTuple;lettypeNameIdOfUnit;lettypeNameIdOfTupleOrUnit;functionbuildTypeMapIndex(name,isAssocType){if(name===""||name===null){returnnull}if(typeNameIdMap.has(name)){constobj=typeNameIdMap.get(name);obj.assocOnly=isAssocType&&obj.assocOnly;returnobj.id}else{constid=typeNameIdMap.size;typeNameIdMap.set(name,{id,assocOnly:isAssocType});returnid}}functionisSpecialStartCharacter(c){return"<\"".indexOf(c)!==-1}functionisEndCharacter(c){return"=,>-])".indexOf(c)!==-1}functionitemTypeFromName(typename){constindex=itemTypes.findIndex(i=>i===typename);if(index<0){throw["Unknown type filter ",typename]}returnindex}functiongetStringElem(query,parserState,isInGenerics){if(isInGenerics){throw["Unexpected ","\""," in generics"]}elseif(query.literalSearch){throw["Cannot have more than one literal search element"]}elseif(parserState.totalElems-parserState.genericsElems>0){throw["Cannot use literal search when there is more than one element"]}parserState.pos+=
</div>`);const description=document.createElement("div");description.className="desc";description.insertAdjacentHTML("beforeend",item.desc);link.appendChild(description);output.appendChild(link)})}else if(query.error===null){output.className="search-failed"+extraClass;output.innerHTML="No results :(<br/>"+"Tryon<ahref=\"https://duckduckgo.com/?q="+encodeURIComponent("rust "+query.userQuery)+"\">DuckDuckGo</a>?<br/><br/>"+"Or try looking in one of these:<ul><li>The <a "+"href=\"https://doc.rust-lang.org/reference/index.html\">Rust Reference</a> "+" for technical details about the language.</li><li><a "+"href=\"https://doc.rust-lang.org/rust-by-example/index.html\">Rust By "+"Example</a> for expository code examples.</a></li><li>The <a "+"href=\"https://doc.rust-lang.org/book/index.html\">Rust Book</a> for "+"introductions to language features and the language itself.</li><li><a "+"href=\"https://docs.rs\">Docs.rs</a> for documentation of crates released on"+" <a href=\"https://crates.io/\">crates.io</a>.</li></ul>"}return[output,array.length]}functionmakeTabHeader(tabNb,text,nbElems){constfmtNbElems=nbElems<10?`\u{2007}(${nbElems})\u{2007}\u{2007}`:nbElems<100?`\u{2007}(${nbElems})\u{2007}`:`\u{2007}(${nbElems})`;if(searchState.currentTab===tabNb){return"<button class=\"selected\">"+text+"<span class=\"count\">"+fmtNbElems+"</span></button>"}return"<button>"+text+"<span class=\"count\">"+fmtNbElems+"</span></button>"}functionshowResults(results,go_to_first,filterCrates){constsearch=searchState.outputElement();if(go_to_first||(results.others.length===1&&getSettingValue("go-to-only-result")==="true")){window.onunload=()=>{};searchState.removeQueryParameters();constelem=document.createElement("a");elem.href=results.others[0].href;removeClass(elem,"active");document.body.appendChild(elem);elem.click();return}if(results.query===undefined){results.query=parseQuery(searchState.input.value)}currentResults=results.query.userQuery;constret_others=addTab(results.others,results.query,true);constret_in_args=addTab(results.in_args,results.query,false);constret_returned=addTab(results.returned,results.query,false);letcurrentTab=searchState.currentTab;if((currentTab===0&&ret_others[1]===0)||(currentTab===1&&ret_in_args[1]===0)||(currentTab===2&&ret_returned[1]===0)){if(ret_others[1]!==0){currentTab=0}elseif(ret_in_args[1]!==0){currentTab=1}elseif(ret_returned[1]!==0){currentTab=2}}letcrates="";if(rawSearchIndex.size>1){crates=" in <div id=\"crate-search-div\"><select id=\"crate-search\">"+"<option value=\"all crates\">all crates</option>";for(constcofrawSearchIndex.keys()){crates+=`<option value="${c}" ${c===filterCrates&&"selected"}>${c}</option>`}crates+="</select></div>"}letoutput=`<h1 class="search-results-title">Results${crates}</h1>`;if(results.query.error!==null){consterror=results.query.error;error.forEach((value,index)=>{value=value.split("<").join("<").split(">").join(">");if(index%2!==0){error[index]=`<code>${value.replaceAll(" "," ")}</code>`}else{error[index]=value}});output+=`<h3 class="error">Query parser error: "${error.join("")}".</h3>`;output+="<div id=\"search-tabs\">"+makeTabHeader(0,"In Names",ret_others[1])+"</div>";currentTab=0}elseif(results.query.foundElems<=1&&results.query.returned.length===0){output+="<div id=\"search-tabs\">"+makeTabHeader(0,"In Names",ret_others[1])+makeTabHeader(1,"In Parameters",ret_in_args[1])+makeTabHeader(2,"In Return Types",ret_returned[1])+"</div>"}else{constsignatureTabTitle=results.query.elems.length===0?"In Function Return Types":results.query.returned.length===0?"In Function Parameters":"In Function Signatures";output+="<div id=\"search-tabs\">"+makeTabHeader(0,signatureTabTitle,ret_others[1])+"</div>";currentTab=0}if(results.query.correction!==null){constorig=results.query.returned.length>0?results.query.returned[0].name:results.query.elems[0].name;output+="<h3 class=\"search-corrections\">"+`Type "${orig}" not found. `+"Showing results for closest type name "+`"${results.query.correction}" instead.</h3>`}if(results.query.proposeCorrec