")?;
for m in &provided {
trait_item(w, cx, *m, it)?;
}
- write!(w, "
")?;
+ write_loading_content(w, "
")?;
}
// If there are methods directly on this trait object, render them here.
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)?;
let cache = cache();
- let impl_header = "\
-
")?;
for implementor in synthetic {
synthetic_types.extend(
collect_paths_for_type(implementor.inner_impl().for_.clone())
);
render_implementor(cx, implementor, w, &implementor_dups)?;
}
- write!(w, "
")?;
+ write_loading_content(w, "
")?;
}
} else {
// even without any implementations to write in, we still want the heading and list, so the
// implementors javascript file pulled in below has somewhere to write the impls into
- write!(w, "{}", impl_header)?;
- write!(w, "")?;
+ write_small_section_header(w, "implementors", "Implementors",
+ "
";
- addClass(document.getElementById('main'), 'hidden');
- var search = document.getElementById('search');
- removeClass(search, 'hidden');
+ addClass(main, "hidden");
+ var search = document.getElementById("search");
+ removeClass(search, "hidden");
search.innerHTML = output;
- var tds = search.getElementsByTagName('td');
+ var tds = search.getElementsByTagName("td");
var td_width = 0;
if (tds.length > 0) {
td_width = tds[0].offsetWidth;
}
var width = search.offsetWidth - 40 - td_width;
- onEach(search.getElementsByClassName('desc'), function(e) {
- e.style.width = width + 'px';
+ onEachLazy(search.getElementsByClassName("desc"), function(e) {
+ e.style.width = width + "px";
});
initSearchNav();
- var elems = document.getElementById('titles').childNodes;
+ var elems = document.getElementById("titles").childNodes;
elems[0].onclick = function() { printTab(0); };
elems[1].onclick = function() { printTab(1); };
elems[2].onclick = function() { printTab(2); };
@@ -1389,74 +1427,74 @@ if (!String.prototype.endsWith) {
}
function execSearch(query, searchWords, filterCrates) {
+ function getSmallest(arrays, positions, notDuplicates) {
+ var start = null;
+
+ for (var it = 0; it < positions.length; ++it) {
+ if (arrays[it].length > positions[it] &&
+ (start === null || start > arrays[it][positions[it]].lev) &&
+ !notDuplicates[arrays[it][positions[it]].fullPath]) {
+ start = arrays[it][positions[it]].lev;
+ }
+ }
+ return start;
+ }
+
+ function mergeArrays(arrays) {
+ var ret = [];
+ var positions = [];
+ var notDuplicates = {};
+
+ for (var x = 0; x < arrays.length; ++x) {
+ positions.push(0);
+ }
+ while (ret.length < MAX_RESULTS) {
+ var smallest = getSmallest(arrays, positions, notDuplicates);
+
+ if (smallest === null) {
+ break;
+ }
+ for (x = 0; x < arrays.length && ret.length < MAX_RESULTS; ++x) {
+ if (arrays[x].length > positions[x] &&
+ arrays[x][positions[x]].lev === smallest &&
+ !notDuplicates[arrays[x][positions[x]].fullPath]) {
+ ret.push(arrays[x][positions[x]]);
+ notDuplicates[arrays[x][positions[x]].fullPath] = true;
+ positions[x] += 1;
+ }
+ }
+ }
+ return ret;
+ }
+
var queries = query.raw.split(",");
var results = {
- 'in_args': [],
- 'returned': [],
- 'others': [],
+ "in_args": [],
+ "returned": [],
+ "others": [],
};
for (var i = 0; i < queries.length; ++i) {
- var query = queries[i].trim();
+ query = queries[i].trim();
if (query.length !== 0) {
var tmp = execQuery(getQuery(query), searchWords, filterCrates);
- results['in_args'].push(tmp['in_args']);
- results['returned'].push(tmp['returned']);
- results['others'].push(tmp['others']);
+ results.in_args.push(tmp.in_args);
+ results.returned.push(tmp.returned);
+ results.others.push(tmp.others);
}
}
if (queries.length > 1) {
- function getSmallest(arrays, positions, notDuplicates) {
- var start = null;
-
- for (var it = 0; it < positions.length; ++it) {
- if (arrays[it].length > positions[it] &&
- (start === null || start > arrays[it][positions[it]].lev) &&
- !notDuplicates[arrays[it][positions[it]].fullPath]) {
- start = arrays[it][positions[it]].lev;
- }
- }
- return start;
- }
-
- function mergeArrays(arrays) {
- var ret = [];
- var positions = [];
- var notDuplicates = {};
-
- for (var x = 0; x < arrays.length; ++x) {
- positions.push(0);
- }
- while (ret.length < MAX_RESULTS) {
- var smallest = getSmallest(arrays, positions, notDuplicates);
-
- if (smallest === null) {
- break;
- }
- for (x = 0; x < arrays.length && ret.length < MAX_RESULTS; ++x) {
- if (arrays[x].length > positions[x] &&
- arrays[x][positions[x]].lev === smallest &&
- !notDuplicates[arrays[x][positions[x]].fullPath]) {
- ret.push(arrays[x][positions[x]]);
- notDuplicates[arrays[x][positions[x]].fullPath] = true;
- positions[x] += 1;
- }
- }
- }
- return ret;
- }
-
return {
- 'in_args': mergeArrays(results['in_args']),
- 'returned': mergeArrays(results['returned']),
- 'others': mergeArrays(results['others']),
+ "in_args": mergeArrays(results.in_args),
+ "returned": mergeArrays(results.returned),
+ "others": mergeArrays(results.others),
};
} else {
return {
- 'in_args': results['in_args'][0],
- 'returned': results['returned'][0],
- 'others': results['others'][0],
+ "in_args": results.in_args[0],
+ "returned": results.returned[0],
+ "others": results.others[0],
};
}
}
@@ -1508,6 +1546,8 @@ if (!String.prototype.endsWith) {
function buildIndex(rawSearchIndex) {
searchIndex = [];
var searchWords = [];
+ var i;
+
for (var crate in rawSearchIndex) {
if (!rawSearchIndex.hasOwnProperty(crate)) { continue; }
@@ -1534,7 +1574,7 @@ if (!String.prototype.endsWith) {
// convert `paths` into an object form
var len = paths.length;
- for (var i = 0; i < len; ++i) {
+ for (i = 0; i < len; ++i) {
paths[i] = {ty: paths[i][0], name: paths[i][1]};
}
@@ -1545,9 +1585,9 @@ if (!String.prototype.endsWith) {
// operation that is cached for the life of the page state so that
// all other search operations have access to this cached data for
// faster analysis operations
- var len = items.length;
+ len = items.length;
var lastPath = "";
- for (var i = 0; i < len; ++i) {
+ for (i = 0; i < len; ++i) {
var rawRow = items[i];
var row = {crate: crate, ty: rawRow[0], name: rawRow[1],
path: rawRow[2] || lastPath, desc: rawRow[3],
@@ -1573,13 +1613,12 @@ if (!String.prototype.endsWith) {
if (browserSupportsHistoryApi()) {
history.replaceState("", "std - Rust", "?search=");
}
- var main = document.getElementById('main');
- if (hasClass(main, 'content')) {
- removeClass(main, 'hidden');
+ if (hasClass(main, "content")) {
+ removeClass(main, "hidden");
}
- var search_c = document.getElementById('search');
- if (hasClass(search_c, 'content')) {
- addClass(search_c, 'hidden');
+ var search_c = document.getElementById("search");
+ if (hasClass(search_c, "content")) {
+ addClass(search_c, "hidden");
}
} else {
searchTimeout = setTimeout(search, 500);
@@ -1620,13 +1659,12 @@ if (!String.prototype.endsWith) {
// When browsing back from search results the main page
// visibility must be reset.
if (!params.search) {
- var main = document.getElementById('main');
- if (hasClass(main, 'content')) {
- removeClass(main, 'hidden');
+ if (hasClass(main, "content")) {
+ removeClass(main, "hidden");
}
- var search_c = document.getElementById('search');
- if (hasClass(search_c, 'content')) {
- addClass(search_c, 'hidden');
+ var search_c = document.getElementById("search");
+ if (hasClass(search_c, "content")) {
+ addClass(search_c, "hidden");
}
}
// Revert to the previous title manually since the History
@@ -1643,9 +1681,9 @@ if (!String.prototype.endsWith) {
if (params.search) {
search_input.value = params.search;
} else {
- search_input.value = '';
+ search_input.value = "";
}
- // Some browsers fire 'onpopstate' for every page load
+ // Some browsers fire "onpopstate" for every page load
// (Chrome), while others fire the event only when actually
// popping a state (Firefox), which is why search() is
// called both here and at the end of the startSearch()
@@ -1660,13 +1698,13 @@ if (!String.prototype.endsWith) {
startSearch();
// Draw a convenient sidebar of known crates if we have a listing
- if (rootPath === '../' || rootPath === "./") {
- var sidebar = document.getElementsByClassName('sidebar-elems')[0];
+ if (rootPath === "../" || rootPath === "./") {
+ var sidebar = document.getElementsByClassName("sidebar-elems")[0];
if (sidebar) {
- var div = document.createElement('div');
- div.className = 'block crate';
- div.innerHTML = '
Crates
';
- var ul = document.createElement('ul');
+ var div = document.createElement("div");
+ div.className = "block crate";
+ div.innerHTML = "
Crates
";
+ var ul = document.createElement("ul");
div.appendChild(ul);
var crates = [];
@@ -1678,17 +1716,17 @@ if (!String.prototype.endsWith) {
}
crates.sort();
for (var i = 0; i < crates.length; ++i) {
- var klass = 'crate';
+ var klass = "crate";
if (rootPath !== "./" && crates[i] === window.currentCrate) {
- klass += ' current';
+ klass += " current";
}
- var link = document.createElement('a');
- link.href = rootPath + crates[i] + '/index.html';
+ var link = document.createElement("a");
+ link.href = rootPath + crates[i] + "/index.html";
link.title = rawSearchIndex[crates[i]].doc;
link.className = klass;
link.textContent = crates[i];
- var li = document.createElement('li');
+ var li = document.createElement("li");
li.appendChild(link);
ul.appendChild(li);
}
@@ -1701,41 +1739,44 @@ if (!String.prototype.endsWith) {
// delayed sidebar rendering.
function initSidebarItems(items) {
- var sidebar = document.getElementsByClassName('sidebar-elems')[0];
+ var sidebar = document.getElementsByClassName("sidebar-elems")[0];
var current = window.sidebarCurrent;
function block(shortty, longty) {
var filtered = items[shortty];
- if (!filtered) { return; }
+ if (!filtered) {
+ return;
+ }
- var div = document.createElement('div');
- div.className = 'block ' + shortty;
- var h3 = document.createElement('h3');
+ var div = document.createElement("div");
+ div.className = "block " + shortty;
+ var h3 = document.createElement("h3");
h3.textContent = longty;
div.appendChild(h3);
- var ul = document.createElement('ul');
+ var ul = document.createElement("ul");
- for (var i = 0; i < filtered.length; ++i) {
+ var length = filtered.length;
+ for (var i = 0; i < length; ++i) {
var item = filtered[i];
var name = item[0];
var desc = item[1]; // can be null
var klass = shortty;
if (name === current.name && shortty === current.ty) {
- klass += ' current';
+ klass += " current";
}
var path;
- if (shortty === 'mod') {
- path = name + '/index.html';
+ if (shortty === "mod") {
+ path = name + "/index.html";
} else {
- path = shortty + '.' + name + '.html';
+ path = shortty + "." + name + ".html";
}
- var link = document.createElement('a');
+ var link = document.createElement("a");
link.href = current.relpath + path;
link.title = desc;
link.className = klass;
link.textContent = name;
- var li = document.createElement('li');
+ var li = document.createElement("li");
li.appendChild(link);
ul.appendChild(li);
}
@@ -1763,22 +1804,25 @@ if (!String.prototype.endsWith) {
window.initSidebarItems = initSidebarItems;
window.register_implementors = function(imp) {
- var implementors = document.getElementById('implementors-list');
- var synthetic_implementors = document.getElementById('synthetic-implementors-list');
+ var implementors = document.getElementById("implementors-list");
+ var synthetic_implementors = document.getElementById("synthetic-implementors-list");
var libs = Object.getOwnPropertyNames(imp);
- for (var i = 0; i < libs.length; ++i) {
+ var llength = libs.length;
+ for (var i = 0; i < llength; ++i) {
if (libs[i] === currentCrate) { continue; }
var structs = imp[libs[i]];
+ var slength = structs.length;
struct_loop:
- for (var j = 0; j < structs.length; ++j) {
+ for (var j = 0; j < slength; ++j) {
var struct = structs[j];
var list = struct.synthetic ? synthetic_implementors : implementors;
if (struct.synthetic) {
- for (var k = 0; k < struct.types.length; k++) {
+ var stlength = struct.types.length;
+ for (var k = 0; k < stlength; k++) {
if (window.inlined_types.has(struct.types[k])) {
continue struct_loop;
}
@@ -1786,21 +1830,22 @@ if (!String.prototype.endsWith) {
}
}
- var code = document.createElement('code');
+ var code = document.createElement("code");
code.innerHTML = struct.text;
- var x = code.getElementsByTagName('a');
- for (var k = 0; k < x.length; k++) {
- var href = x[k].getAttribute('href');
- if (href && href.indexOf('http') !== 0) {
- x[k].setAttribute('href', rootPath + href);
+ var x = code.getElementsByTagName("a");
+ var xlength = x.length;
+ for (var it = 0; it < xlength; it++) {
+ var href = x[it].getAttribute("href");
+ if (href && href.indexOf("http") !== 0) {
+ x[it].setAttribute("href", rootPath + href);
}
}
- var display = document.createElement('h3');
+ var display = document.createElement("h3");
addClass(display, "impl");
- display.innerHTML = '
\
-
' + code.outerHTML + '
\
- ';
+ display.innerHTML = "
" +
+ "
" + code.outerHTML + "
" +
+ "
";
list.appendChild(display);
}
}
@@ -1816,47 +1861,49 @@ if (!String.prototype.endsWith) {
}
// button will collapse the section
// note that this text is also set in the HTML template in render.rs
- return "\u2212"; // "\u2212" is '−' minus sign
+ return "\u2212"; // "\u2212" is "−" minus sign
}
function onEveryMatchingChild(elem, className, func) {
if (elem && className && func) {
- for (var i = 0; i < elem.childNodes.length; i++) {
- if (hasClass(elem.childNodes[i], className)) {
- func(elem.childNodes[i]);
+ var length = elem.childNodes.length;
+ var nodes = elem.childNodes;
+ for (var i = 0; i < length; ++i) {
+ if (hasClass(nodes[i], className)) {
+ func(nodes[i]);
} else {
- onEveryMatchingChild(elem.childNodes[i], className, func);
+ onEveryMatchingChild(nodes[i], className, func);
}
}
}
}
function toggleAllDocs(pageId, fromAutoCollapse) {
- var toggle = document.getElementById("toggle-all-docs");
- if (!toggle) {
+ var innerToggle = document.getElementById("toggle-all-docs");
+ if (!innerToggle) {
return;
}
- if (hasClass(toggle, "will-expand")) {
+ if (hasClass(innerToggle, "will-expand")) {
updateLocalStorage("rustdoc-collapse", "false");
- removeClass(toggle, "will-expand");
- onEveryMatchingChild(toggle, "inner", function(e) {
+ removeClass(innerToggle, "will-expand");
+ onEveryMatchingChild(innerToggle, "inner", function(e) {
e.innerHTML = labelForToggleButton(false);
});
- toggle.title = "collapse all docs";
+ innerToggle.title = "collapse all docs";
if (fromAutoCollapse !== true) {
- onEach(document.getElementsByClassName("collapse-toggle"), function(e) {
+ onEachLazy(document.getElementsByClassName("collapse-toggle"), function(e) {
collapseDocs(e, "show");
});
}
} else {
updateLocalStorage("rustdoc-collapse", "true");
- addClass(toggle, "will-expand");
- onEveryMatchingChild(toggle, "inner", function(e) {
+ addClass(innerToggle, "will-expand");
+ onEveryMatchingChild(innerToggle, "inner", function(e) {
e.innerHTML = labelForToggleButton(true);
});
- toggle.title = "expand all docs";
+ innerToggle.title = "expand all docs";
if (fromAutoCollapse !== true) {
- onEach(document.getElementsByClassName("collapse-toggle"), function(e) {
+ onEachLazy(document.getElementsByClassName("collapse-toggle"), function(e) {
collapseDocs(e, "hide", pageId);
});
}
@@ -1870,27 +1917,58 @@ if (!String.prototype.endsWith) {
function adjustToggle(arg) {
return function(e) {
- if (hasClass(e, 'toggle-label')) {
+ if (hasClass(e, "toggle-label")) {
if (arg) {
- e.style.display = 'inline-block';
+ e.style.display = "inline-block";
} else {
- e.style.display = 'none';
+ e.style.display = "none";
}
}
- if (hasClass(e, 'inner')) {
+ if (hasClass(e, "inner")) {
e.innerHTML = labelForToggleButton(arg);
}
};
- };
+ }
- if (!hasClass(toggle.parentNode, "impl")) {
- var relatedDoc = toggle.parentNode.nextElementSibling;
+ function implHider(addOrRemove) {
+ return function(n) {
+ var is_method = hasClass(n, "method");
+ if (is_method || hasClass(n, "type")) {
+ if (is_method === true) {
+ if (addOrRemove) {
+ addClass(n, "hidden-by-impl-hider");
+ } else {
+ removeClass(n, "hidden-by-impl-hider");
+ }
+ }
+ var ns = n.nextElementSibling;
+ while (true) {
+ if (ns && (
+ hasClass(ns, "docblock") ||
+ hasClass(ns, "stability"))) {
+ if (addOrRemove) {
+ addClass(ns, "hidden-by-impl-hider");
+ } else {
+ removeClass(ns, "hidden-by-impl-hider");
+ }
+ ns = ns.nextElementSibling;
+ continue;
+ }
+ break;
+ }
+ }
+ };
+ }
+
+ var relatedDoc;
+ var action = mode;
+ if (hasClass(toggle.parentNode, "impl") === false) {
+ relatedDoc = toggle.parentNode.nextElementSibling;
if (hasClass(relatedDoc, "stability")) {
relatedDoc = relatedDoc.nextElementSibling;
}
if (hasClass(relatedDoc, "docblock") || hasClass(relatedDoc, "sub-variant")) {
- var action = mode;
- if (action === "toggle") {
+ if (mode === "toggle") {
if (hasClass(relatedDoc, "hidden-by-usual-hider")) {
action = "show";
} else {
@@ -1899,67 +1977,35 @@ if (!String.prototype.endsWith) {
}
if (action === "hide") {
addClass(relatedDoc, "hidden-by-usual-hider");
- onEach(toggle.childNodes, adjustToggle(true));
- addClass(toggle.parentNode, 'collapsed');
+ onEachLazy(toggle.childNodes, adjustToggle(true));
+ addClass(toggle.parentNode, "collapsed");
} else if (action === "show") {
removeClass(relatedDoc, "hidden-by-usual-hider");
- removeClass(toggle.parentNode, 'collapsed');
- onEach(toggle.childNodes, adjustToggle(false));
+ removeClass(toggle.parentNode, "collapsed");
+ onEachLazy(toggle.childNodes, adjustToggle(false));
}
}
} else {
// we are collapsing the impl block
- function implHider(addOrRemove) {
- return function(n) {
- var is_method = hasClass(n, "method");
- if (is_method || hasClass(n, "type")) {
- if (is_method === true) {
- if (addOrRemove) {
- addClass(n, "hidden-by-impl-hider");
- } else {
- removeClass(n, "hidden-by-impl-hider");
- }
- }
- var ns = n.nextElementSibling;
- while (true) {
- if (ns && (
- hasClass(ns, "docblock") ||
- hasClass(ns, "stability"))) {
- if (addOrRemove) {
- addClass(ns, "hidden-by-impl-hider");
- } else {
- removeClass(ns, "hidden-by-impl-hider");
- }
- ns = ns.nextElementSibling;
- continue;
- }
- break;
- }
- }
- }
- }
var parentElem = toggle.parentNode;
- var relatedDoc = parentElem;
+ relatedDoc = parentElem;
var docblock = relatedDoc.nextElementSibling;
- while (!hasClass(relatedDoc, "impl-items")) {
+ while (hasClass(relatedDoc, "impl-items") === false) {
relatedDoc = relatedDoc.nextElementSibling;
}
- if ((!relatedDoc && !hasClass(docblock, "docblock")) ||
- (pageId && onEach(relatedDoc.childNodes, function(e) {
- return e.id === pageId;
- }) === true)) {
+ if ((!relatedDoc && hasClass(docblock, "docblock") === false) ||
+ (pageId && document.getElementById(pageId))) {
return;
}
// Hide all functions, but not associated types/consts
- var action = mode;
- if (action === "toggle") {
+ if (mode === "toggle") {
if (hasClass(relatedDoc, "fns-now-collapsed") ||
- hasClass(docblock, "hidden-by-impl-hider")) {
+ hasClass(docblock, "hidden-by-impl-hider")) {
action = "show";
} else {
action = "hide";
@@ -1969,13 +2015,25 @@ if (!String.prototype.endsWith) {
if (action === "show") {
removeClass(relatedDoc, "fns-now-collapsed");
removeClass(docblock, "hidden-by-usual-hider");
- onEach(toggle.childNodes, adjustToggle(false));
- onEach(relatedDoc.childNodes, implHider(false));
+ onEachLazy(toggle.childNodes, adjustToggle(false));
+ onEachLazy(relatedDoc.childNodes, implHider(false));
} else if (action === "hide") {
addClass(relatedDoc, "fns-now-collapsed");
addClass(docblock, "hidden-by-usual-hider");
- onEach(toggle.childNodes, adjustToggle(true));
- onEach(relatedDoc.childNodes, implHider(true));
+ onEachLazy(toggle.childNodes, adjustToggle(true));
+ onEachLazy(relatedDoc.childNodes, implHider(true));
+ }
+ }
+ }
+
+ function collapser(e, collapse) {
+ // inherent impl ids are like "impl" or impl-'.
+ // they will never be hidden by default.
+ var n = e.parentElement;
+ if (n.id.match(/^impl(?:-\d+)?$/) === null) {
+ // Automatically minimize all non-inherent impls
+ if (collapse || hasClass(n, "impl")) {
+ collapseDocs(e, "hide", pageId);
}
}
}
@@ -1983,88 +2041,112 @@ if (!String.prototype.endsWith) {
function autoCollapse(pageId, collapse) {
if (collapse) {
toggleAllDocs(pageId, true);
- }
- var collapser = function(e) {
- // inherent impl ids are like 'impl' or impl-'.
- // they will never be hidden by default.
- var n = e.parentElement;
- if (n.id.match(/^impl(?:-\d+)?$/) === null) {
- // Automatically minimize all non-inherent impls
- if (collapse || hasClass(n, 'impl')) {
- collapseDocs(e, "hide", pageId);
- }
- }
- };
- if (getCurrentValue('rustdoc-trait-implementations') !== "false") {
- var impl_list = document.getElementById('implementations-list');
+ } else if (getCurrentValue("rustdoc-trait-implementations") !== "false") {
+ var impl_list = document.getElementById("implementations-list");
if (impl_list !== null) {
- onEach(impl_list.getElementsByClassName("collapse-toggle"), collapser);
- }
- }
- if (getCurrentValue('rustdoc-method-docs') !== "false") {
- var implItems = document.getElementsByClassName('impl-items');
-
- if (implItems && implItems.length > 0) {
- onEach(implItems, function(elem) {
- onEach(elem.getElementsByClassName("collapse-toggle"), collapser);
+ onEachLazy(impl_list.getElementsByClassName("collapse-toggle"), function(e) {
+ collapser(e, collapse);
});
}
}
}
- var x = document.getElementById('toggle-all-docs');
- if (x) {
- x.onclick = toggleAllDocs;
+ var toggles = document.getElementById("toggle-all-docs");
+ if (toggles) {
+ toggles.onclick = toggleAllDocs;
}
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
- function checkIfThereAreMethods(elems) {
- var areThereMethods = false;
-
- onEach(elems, function(e) {
- if (hasClass(e, "method")) {
- areThereMethods = true;
- return true;
- }
- });
- return areThereMethods;
+ function createSimpleToggle(sectionIsCollapsed) {
+ var toggle = document.createElement("a");
+ toggle.href = "javascript:void(0)";
+ toggle.className = "collapse-toggle";
+ toggle.innerHTML = "[" + labelForToggleButton(sectionIsCollapsed) +
+ "]";
+ return toggle;
}
- var toggle = document.createElement('a');
- toggle.href = 'javascript:void(0)';
- toggle.className = 'collapse-toggle';
- toggle.innerHTML = "[" + labelForToggleButton(false) + "]";
+ var toggle = createSimpleToggle(false);
var func = function(e) {
var next = e.nextElementSibling;
- if (hasClass(e, 'impl') && next && hasClass(next, 'docblock')) {
+ if (!next) {
+ return;
+ }
+ if (hasClass(next, "docblock") ||
+ (hasClass(next, "stability") &&
+ hasClass(next.nextElementSibling, "docblock"))) {
+ insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]);
+ }
+ };
+
+ var funcImpl = function(e) {
+ var next = e.nextElementSibling;
+ if (next && hasClass(next, "docblock")) {
next = next.nextElementSibling;
}
if (!next) {
return;
}
- if ((hasClass(e, 'method') || hasClass(e, 'associatedconstant') ||
- checkIfThereAreMethods(next.childNodes)) &&
- (hasClass(next, 'docblock') ||
- hasClass(e, 'impl') ||
- (hasClass(next, 'stability') &&
- hasClass(next.nextElementSibling, 'docblock')))) {
+ if (next.getElementsByClassName("method").length > 0 && hasClass(e, "impl")) {
insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]);
}
};
- onEach(document.getElementsByClassName('method'), func);
- onEach(document.getElementsByClassName('associatedconstant'), func);
- onEach(document.getElementsByClassName('impl'), func);
- onEach(document.getElementsByClassName('impl-items'), function(e) {
- onEach(e.getElementsByClassName('associatedconstant'), func);
- var hiddenElems = e.getElementsByClassName('hidden');
+
+ onEachLazy(document.getElementsByClassName("method"), func);
+ onEachLazy(document.getElementsByClassName("associatedconstant"), func);
+ onEachLazy(document.getElementsByClassName("impl"), funcImpl);
+ var impl_call = function() {};
+ if (getCurrentValue("rustdoc-method-docs") !== "false") {
+ impl_call = function(e, newToggle, pageId) {
+ if (e.id.match(/^impl(?:-\d+)?$/) === null) {
+ // Automatically minimize all non-inherent impls
+ if (hasClass(e, "impl")) {
+ collapseDocs(newToggle, "hide", pageId);
+ }
+ }
+ };
+ }
+ var pageId = getPageId();
+ var newToggle = document.createElement("a");
+ newToggle.href = "javascript:void(0)";
+ newToggle.className = "collapse-toggle hidden-default collapsed";
+ newToggle.innerHTML = "[" + labelForToggleButton(true) +
+ "] Show hidden undocumented items";
+ function toggleClicked() {
+ if (hasClass(this, "collapsed")) {
+ removeClass(this, "collapsed");
+ onEachLazy(this.parentNode.getElementsByClassName("hidden"), function(x) {
+ if (hasClass(x, "content") === false) {
+ removeClass(x, "hidden");
+ addClass(x, "x");
+ }
+ }, true);
+ this.innerHTML = "[" + labelForToggleButton(false) +
+ "] Hide undocumented items";
+ } else {
+ addClass(this, "collapsed");
+ onEachLazy(this.parentNode.getElementsByClassName("x"), function(x) {
+ if (hasClass(x, "content") === false) {
+ addClass(x, "hidden");
+ removeClass(x, "x");
+ }
+ }, true);
+ this.innerHTML = "[" + labelForToggleButton(true) +
+ "] Show hidden undocumented items";
+ }
+ }
+ onEachLazy(document.getElementsByClassName("impl-items"), function(e) {
+ onEachLazy(e.getElementsByClassName("associatedconstant"), func);
+ var hiddenElems = e.getElementsByClassName("hidden");
var needToggle = false;
- for (var i = 0; i < hiddenElems.length; ++i) {
+ var hlength = hiddenElems.length;
+ for (var i = 0; i < hlength; ++i) {
if (hasClass(hiddenElems[i], "content") === false &&
hasClass(hiddenElems[i], "docblock") === false) {
needToggle = true;
@@ -2072,46 +2154,21 @@ if (!String.prototype.endsWith) {
}
}
if (needToggle === true) {
- var newToggle = document.createElement('a');
- newToggle.href = 'javascript:void(0)';
- newToggle.className = 'collapse-toggle hidden-default collapsed';
- newToggle.innerHTML = "[" + labelForToggleButton(true) + "" +
- "] Show hidden undocumented items";
- newToggle.onclick = function() {
- if (hasClass(this, "collapsed")) {
- removeClass(this, "collapsed");
- onEach(this.parentNode.getElementsByClassName("hidden"), function(x) {
- if (hasClass(x, "content") === false) {
- removeClass(x, "hidden");
- addClass(x, "x");
- }
- }, true);
- this.innerHTML = "[" + labelForToggleButton(false) +
- "] Hide undocumented items"
- } else {
- addClass(this, "collapsed");
- onEach(this.parentNode.getElementsByClassName("x"), function(x) {
- if (hasClass(x, "content") === false) {
- addClass(x, "hidden");
- removeClass(x, "x");
- }
- }, true);
- this.innerHTML = "[" + labelForToggleButton(true) +
- "] Show hidden undocumented items";
- }
- };
- e.insertBefore(newToggle, e.firstChild);
+ var inner_toggle = newToggle.cloneNode(true);
+ inner_toggle.onclick = toggleClicked;
+ e.insertBefore(inner_toggle, e.firstChild);
+ impl_call(e, inner_toggle, pageId);
}
});
function createToggle(otherMessage, fontSize, extraClass, show) {
- var span = document.createElement('span');
- span.className = 'toggle-label';
+ var span = document.createElement("span");
+ span.className = "toggle-label";
if (show) {
- span.style.display = 'none';
+ span.style.display = "none";
}
if (!otherMessage) {
- span.innerHTML = ' Expand description';
+ span.innerHTML = " Expand description";
} else {
span.innerHTML = otherMessage;
}
@@ -2123,13 +2180,13 @@ if (!String.prototype.endsWith) {
var mainToggle = toggle.cloneNode(true);
mainToggle.appendChild(span);
- var wrapper = document.createElement('div');
- wrapper.className = 'toggle-wrapper';
+ var wrapper = document.createElement("div");
+ wrapper.className = "toggle-wrapper";
if (!show) {
- addClass(wrapper, 'collapsed');
- var inner = mainToggle.getElementsByClassName('inner');
+ addClass(wrapper, "collapsed");
+ var inner = mainToggle.getElementsByClassName("inner");
if (inner && inner.length > 0) {
- inner[0].innerHTML = '+';
+ inner[0].innerHTML = "+";
}
}
if (extraClass) {
@@ -2139,21 +2196,21 @@ if (!String.prototype.endsWith) {
return wrapper;
}
- var showItemDeclarations = getCurrentValue('rustdoc-item-declarations') === "false";
+ var showItemDeclarations = getCurrentValue("rustdoc-item-declarations") === "false";
function buildToggleWrapper(e) {
- if (hasClass(e, 'autohide')) {
+ if (hasClass(e, "autohide")) {
var wrap = e.previousElementSibling;
- if (wrap && hasClass(wrap, 'toggle-wrapper')) {
- var toggle = wrap.childNodes[0];
- var extra = e.childNodes[0].tagName === 'H3';
+ if (wrap && hasClass(wrap, "toggle-wrapper")) {
+ var inner_toggle = wrap.childNodes[0];
+ var extra = e.childNodes[0].tagName === "H3";
- e.style.display = 'none';
- addClass(wrap, 'collapsed');
- onEach(toggle.getElementsByClassName('inner'), function(e) {
+ e.style.display = "none";
+ addClass(wrap, "collapsed");
+ onEachLazy(inner_toggle.getElementsByClassName("inner"), function(e) {
e.innerHTML = labelForToggleButton(true);
});
- onEach(toggle.getElementsByClassName('toggle-label'), function(e) {
- e.style.display = 'inline-block';
+ onEachLazy(inner_toggle.getElementsByClassName("toggle-label"), function(e) {
+ e.style.display = "inline-block";
if (extra === true) {
i_e.innerHTML = " Show " + e.childNodes[0].innerHTML;
}
@@ -2161,28 +2218,28 @@ if (!String.prototype.endsWith) {
}
}
if (e.parentNode.id === "main") {
- var otherMessage = '';
+ var otherMessage = "";
var fontSize;
var extraClass;
if (hasClass(e, "type-decl")) {
fontSize = "20px";
- otherMessage = ' Show declaration';
+ otherMessage = " Show declaration";
if (showItemDeclarations === false) {
- extraClass = 'collapsed';
+ extraClass = "collapsed";
}
} else if (hasClass(e, "sub-variant")) {
- otherMessage = ' Show fields';
+ otherMessage = " Show fields";
} else if (hasClass(e, "non-exhaustive")) {
- otherMessage = ' This ';
+ otherMessage = " This ";
if (hasClass(e, "non-exhaustive-struct")) {
- otherMessage += 'struct';
+ otherMessage += "struct";
} else if (hasClass(e, "non-exhaustive-enum")) {
- otherMessage += 'enum';
+ otherMessage += "enum";
} else if (hasClass(e, "non-exhaustive-type")) {
- otherMessage += 'type';
+ otherMessage += "type";
}
- otherMessage += ' is marked as non-exhaustive';
+ otherMessage += " is marked as non-exhaustive";
} else if (hasClass(e.childNodes[0], "impl-items")) {
extraClass = "marg-left";
}
@@ -2199,21 +2256,8 @@ if (!String.prototype.endsWith) {
}
}
- onEach(document.getElementsByClassName('docblock'), buildToggleWrapper);
- onEach(document.getElementsByClassName('sub-variant'), buildToggleWrapper);
-
- function createToggleWrapper(tog) {
- var span = document.createElement('span');
- span.className = 'toggle-label';
- span.style.display = 'none';
- span.innerHTML = ' Expand attributes';
- tog.appendChild(span);
-
- var wrapper = document.createElement('div');
- wrapper.className = 'toggle-wrapper toggle-attributes';
- wrapper.appendChild(tog);
- return wrapper;
- }
+ onEachLazy(document.getElementsByClassName("docblock"), buildToggleWrapper);
+ onEachLazy(document.getElementsByClassName("sub-variant"), buildToggleWrapper);
// In the search display, allows to switch between tabs.
function printTab(nb) {
@@ -2221,24 +2265,37 @@ if (!String.prototype.endsWith) {
currentTab = nb;
}
var nb_copy = nb;
- onEach(document.getElementById('titles').childNodes, function(elem) {
+ onEachLazy(document.getElementById("titles").childNodes, function(elem) {
if (nb_copy === 0) {
- addClass(elem, 'selected');
+ addClass(elem, "selected");
} else {
- removeClass(elem, 'selected');
+ removeClass(elem, "selected");
}
nb_copy -= 1;
});
- onEach(document.getElementById('results').childNodes, function(elem) {
+ onEachLazy(document.getElementById("results").childNodes, function(elem) {
if (nb === 0) {
- elem.style.display = '';
+ elem.style.display = "";
} else {
- elem.style.display = 'none';
+ elem.style.display = "none";
}
nb -= 1;
});
}
+ function createToggleWrapper(tog) {
+ var span = document.createElement("span");
+ span.className = "toggle-label";
+ span.style.display = "none";
+ span.innerHTML = " Expand attributes";
+ tog.appendChild(span);
+
+ var wrapper = document.createElement("div");
+ wrapper.className = "toggle-wrapper toggle-attributes";
+ wrapper.appendChild(tog);
+ return wrapper;
+ }
+
// To avoid checking on "rustdoc-item-attributes" value on every loop...
var itemAttributesFunc = function() {};
if (getCurrentValue("rustdoc-item-attributes") !== "false") {
@@ -2246,8 +2303,9 @@ if (!String.prototype.endsWith) {
collapseDocs(x.previousSibling.childNodes[0], "toggle");
};
}
- onEach(document.getElementById('main').getElementsByClassName('attributes'), function(i_e) {
- i_e.parentNode.insertBefore(createToggleWrapper(toggle.cloneNode(true)), i_e);
+ var attributesToggle = createToggleWrapper(createSimpleToggle(false));
+ onEachLazy(main.getElementsByClassName("attributes"), function(i_e) {
+ i_e.parentNode.insertBefore(attributesToggle.cloneNode(true), i_e);
itemAttributesFunc(i_e);
});
@@ -2255,45 +2313,45 @@ if (!String.prototype.endsWith) {
var lineNumbersFunc = function() {};
if (getCurrentValue("rustdoc-line-numbers") === "true") {
lineNumbersFunc = function(x) {
- var count = x.textContent.split('\n').length;
+ var count = x.textContent.split("\n").length;
var elems = [];
for (var i = 0; i < count; ++i) {
elems.push(i + 1);
}
- var node = document.createElement('pre');
- addClass(node, 'line-number');
- node.innerHTML = elems.join('\n');
+ var node = document.createElement("pre");
+ addClass(node, "line-number");
+ node.innerHTML = elems.join("\n");
x.parentNode.insertBefore(node, x);
};
}
- onEach(document.getElementsByClassName('rust-example-rendered'), function(e) {
- if (hasClass(e, 'compile_fail')) {
+ onEachLazy(document.getElementsByClassName("rust-example-rendered"), function(e) {
+ if (hasClass(e, "compile_fail")) {
e.addEventListener("mouseover", function(event) {
- this.parentElement.previousElementSibling.childNodes[0].style.color = '#f00';
+ this.parentElement.previousElementSibling.childNodes[0].style.color = "#f00";
});
e.addEventListener("mouseout", function(event) {
- this.parentElement.previousElementSibling.childNodes[0].style.color = '';
+ this.parentElement.previousElementSibling.childNodes[0].style.color = "";
});
- } else if (hasClass(e, 'ignore')) {
+ } else if (hasClass(e, "ignore")) {
e.addEventListener("mouseover", function(event) {
- this.parentElement.previousElementSibling.childNodes[0].style.color = '#ff9200';
+ this.parentElement.previousElementSibling.childNodes[0].style.color = "#ff9200";
});
e.addEventListener("mouseout", function(event) {
- this.parentElement.previousElementSibling.childNodes[0].style.color = '';
+ this.parentElement.previousElementSibling.childNodes[0].style.color = "";
});
}
lineNumbersFunc(e);
});
function showModal(content) {
- var modal = document.createElement('div');
+ var modal = document.createElement("div");
modal.id = "important";
- addClass(modal, 'modal');
- modal.innerHTML = '