Initial commit
This commit is contained in:
commit
918fbf9c09
4
FontAwesome/css/font-awesome.css
vendored
Normal file
4
FontAwesome/css/font-awesome.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
FontAwesome/fonts/fontawesome-webfont.ttf
Normal file
BIN
FontAwesome/fonts/fontawesome-webfont.ttf
Normal file
Binary file not shown.
BIN
FontAwesome/fonts/fontawesome-webfont.woff2
Normal file
BIN
FontAwesome/fonts/fontawesome-webfont.woff2
Normal file
Binary file not shown.
227
appendix-00.html
Normal file
227
appendix-00.html
Normal file
File diff suppressed because one or more lines are too long
333
appendix-01-keywords.html
Normal file
333
appendix-01-keywords.html
Normal file
File diff suppressed because one or more lines are too long
395
appendix-02-operators.html
Normal file
395
appendix-02-operators.html
Normal file
File diff suppressed because one or more lines are too long
365
appendix-03-derivable-traits.html
Normal file
365
appendix-03-derivable-traits.html
Normal file
File diff suppressed because one or more lines are too long
343
appendix-04-useful-development-tools.html
Normal file
343
appendix-04-useful-development-tools.html
Normal file
File diff suppressed because one or more lines are too long
272
appendix-05-editions.html
Normal file
272
appendix-05-editions.html
Normal file
File diff suppressed because one or more lines are too long
246
appendix-06-translation.html
Normal file
246
appendix-06-translation.html
Normal file
File diff suppressed because one or more lines are too long
370
appendix-07-nightly-rust.html
Normal file
370
appendix-07-nightly-rust.html
Normal file
File diff suppressed because one or more lines are too long
79
ayu-highlight.css
Normal file
79
ayu-highlight.css
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
Based off of the Ayu theme
|
||||||
|
Original by Dempfi (https://github.com/dempfi/ayu)
|
||||||
|
*/
|
||||||
|
|
||||||
|
.hljs {
|
||||||
|
display: block;
|
||||||
|
overflow-x: auto;
|
||||||
|
background: #191f26;
|
||||||
|
color: #e6e1cf;
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-comment,
|
||||||
|
.hljs-quote,
|
||||||
|
.hljs-meta {
|
||||||
|
color: #5c6773;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-variable,
|
||||||
|
.hljs-template-variable,
|
||||||
|
.hljs-attribute,
|
||||||
|
.hljs-attr,
|
||||||
|
.hljs-regexp,
|
||||||
|
.hljs-link,
|
||||||
|
.hljs-selector-id,
|
||||||
|
.hljs-selector-class {
|
||||||
|
color: #ff7733;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-number,
|
||||||
|
.hljs-builtin-name,
|
||||||
|
.hljs-literal,
|
||||||
|
.hljs-type,
|
||||||
|
.hljs-params {
|
||||||
|
color: #ffee99;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-string,
|
||||||
|
.hljs-bullet {
|
||||||
|
color: #b8cc52;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-title,
|
||||||
|
.hljs-built_in,
|
||||||
|
.hljs-section {
|
||||||
|
color: #ffb454;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-keyword,
|
||||||
|
.hljs-selector-tag,
|
||||||
|
.hljs-symbol {
|
||||||
|
color: #ff7733;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-name {
|
||||||
|
color: #36a3d9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-tag {
|
||||||
|
color: #00568d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-emphasis {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-addition {
|
||||||
|
color: #91b362;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hljs-deletion {
|
||||||
|
color: #d96c75;
|
||||||
|
}
|
605
book.js
Normal file
605
book.js
Normal file
@ -0,0 +1,605 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Fix back button cache problem
|
||||||
|
window.onunload = function () { };
|
||||||
|
|
||||||
|
// Global variable, shared between modules
|
||||||
|
function playpen_text(playpen) {
|
||||||
|
let code_block = playpen.querySelector("code");
|
||||||
|
|
||||||
|
if (window.ace && code_block.classList.contains("editable")) {
|
||||||
|
let editor = window.ace.edit(code_block);
|
||||||
|
return editor.getValue();
|
||||||
|
} else {
|
||||||
|
return code_block.textContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(function codeSnippets() {
|
||||||
|
function fetch_with_timeout(url, options, timeout = 6000) {
|
||||||
|
return Promise.race([
|
||||||
|
fetch(url, options),
|
||||||
|
new Promise((_, reject) => setTimeout(() => reject(new Error('timeout')), timeout))
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var playpens = Array.from(document.querySelectorAll(".playpen"));
|
||||||
|
if (playpens.length > 0) {
|
||||||
|
fetch_with_timeout("https://play.rust-lang.org/meta/crates", {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': "application/json",
|
||||||
|
},
|
||||||
|
method: 'POST',
|
||||||
|
mode: 'cors',
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => {
|
||||||
|
// get list of crates available in the rust playground
|
||||||
|
let playground_crates = response.crates.map(item => item["id"]);
|
||||||
|
playpens.forEach(block => handle_crate_list_update(block, playground_crates));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_crate_list_update(playpen_block, playground_crates) {
|
||||||
|
// update the play buttons after receiving the response
|
||||||
|
update_play_button(playpen_block, playground_crates);
|
||||||
|
|
||||||
|
// and install on change listener to dynamically update ACE editors
|
||||||
|
if (window.ace) {
|
||||||
|
let code_block = playpen_block.querySelector("code");
|
||||||
|
if (code_block.classList.contains("editable")) {
|
||||||
|
let editor = window.ace.edit(code_block);
|
||||||
|
editor.addEventListener("change", function (e) {
|
||||||
|
update_play_button(playpen_block, playground_crates);
|
||||||
|
});
|
||||||
|
// add Ctrl-Enter command to execute rust code
|
||||||
|
editor.commands.addCommand({
|
||||||
|
name: "run",
|
||||||
|
bindKey: {
|
||||||
|
win: "Ctrl-Enter",
|
||||||
|
mac: "Ctrl-Enter"
|
||||||
|
},
|
||||||
|
exec: _editor => run_rust_code(playpen_block)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// updates the visibility of play button based on `no_run` class and
|
||||||
|
// used crates vs ones available on http://play.rust-lang.org
|
||||||
|
function update_play_button(pre_block, playground_crates) {
|
||||||
|
var play_button = pre_block.querySelector(".play-button");
|
||||||
|
|
||||||
|
// skip if code is `no_run`
|
||||||
|
if (pre_block.querySelector('code').classList.contains("no_run")) {
|
||||||
|
play_button.classList.add("hidden");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get list of `extern crate`'s from snippet
|
||||||
|
var txt = playpen_text(pre_block);
|
||||||
|
var re = /extern\s+crate\s+([a-zA-Z_0-9]+)\s*;/g;
|
||||||
|
var snippet_crates = [];
|
||||||
|
var item;
|
||||||
|
while (item = re.exec(txt)) {
|
||||||
|
snippet_crates.push(item[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if all used crates are available on play.rust-lang.org
|
||||||
|
var all_available = snippet_crates.every(function (elem) {
|
||||||
|
return playground_crates.indexOf(elem) > -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (all_available) {
|
||||||
|
play_button.classList.remove("hidden");
|
||||||
|
} else {
|
||||||
|
play_button.classList.add("hidden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function run_rust_code(code_block) {
|
||||||
|
var result_block = code_block.querySelector(".result");
|
||||||
|
if (!result_block) {
|
||||||
|
result_block = document.createElement('code');
|
||||||
|
result_block.className = 'result hljs language-bash';
|
||||||
|
|
||||||
|
code_block.append(result_block);
|
||||||
|
}
|
||||||
|
|
||||||
|
let text = playpen_text(code_block);
|
||||||
|
let classes = code_block.querySelector('code').classList;
|
||||||
|
let has_2018 = classes.contains("edition2018");
|
||||||
|
let edition = has_2018 ? "2018" : "2015";
|
||||||
|
|
||||||
|
var params = {
|
||||||
|
version: "stable",
|
||||||
|
optimize: "0",
|
||||||
|
code: text,
|
||||||
|
edition: edition
|
||||||
|
};
|
||||||
|
|
||||||
|
if (text.indexOf("#![feature") !== -1) {
|
||||||
|
params.version = "nightly";
|
||||||
|
}
|
||||||
|
|
||||||
|
result_block.innerText = "Running...";
|
||||||
|
|
||||||
|
fetch_with_timeout("https://play.rust-lang.org/evaluate.json", {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': "application/json",
|
||||||
|
},
|
||||||
|
method: 'POST',
|
||||||
|
mode: 'cors',
|
||||||
|
body: JSON.stringify(params)
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(response => result_block.innerText = response.result)
|
||||||
|
.catch(error => result_block.innerText = "Playground Communication: " + error.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Syntax highlighting Configuration
|
||||||
|
hljs.configure({
|
||||||
|
tabReplace: ' ', // 4 spaces
|
||||||
|
languages: [], // Languages used for auto-detection
|
||||||
|
});
|
||||||
|
|
||||||
|
if (window.ace) {
|
||||||
|
// language-rust class needs to be removed for editable
|
||||||
|
// blocks or highlightjs will capture events
|
||||||
|
Array
|
||||||
|
.from(document.querySelectorAll('code.editable'))
|
||||||
|
.forEach(function (block) { block.classList.remove('language-rust'); });
|
||||||
|
|
||||||
|
Array
|
||||||
|
.from(document.querySelectorAll('code:not(.editable)'))
|
||||||
|
.forEach(function (block) { hljs.highlightBlock(block); });
|
||||||
|
} else {
|
||||||
|
Array
|
||||||
|
.from(document.querySelectorAll('code'))
|
||||||
|
.forEach(function (block) { hljs.highlightBlock(block); });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adding the hljs class gives code blocks the color css
|
||||||
|
// even if highlighting doesn't apply
|
||||||
|
Array
|
||||||
|
.from(document.querySelectorAll('code'))
|
||||||
|
.forEach(function (block) { block.classList.add('hljs'); });
|
||||||
|
|
||||||
|
Array.from(document.querySelectorAll("code.language-rust")).forEach(function (block) {
|
||||||
|
|
||||||
|
var lines = Array.from(block.querySelectorAll('.boring'));
|
||||||
|
// If no lines were hidden, return
|
||||||
|
if (!lines.length) { return; }
|
||||||
|
block.classList.add("hide-boring");
|
||||||
|
|
||||||
|
var buttons = document.createElement('div');
|
||||||
|
buttons.className = 'buttons';
|
||||||
|
buttons.innerHTML = "<button class=\"fa fa-expand\" title=\"Show hidden lines\" aria-label=\"Show hidden lines\"></button>";
|
||||||
|
|
||||||
|
// add expand button
|
||||||
|
var pre_block = block.parentNode;
|
||||||
|
pre_block.insertBefore(buttons, pre_block.firstChild);
|
||||||
|
|
||||||
|
pre_block.querySelector('.buttons').addEventListener('click', function (e) {
|
||||||
|
if (e.target.classList.contains('fa-expand')) {
|
||||||
|
e.target.classList.remove('fa-expand');
|
||||||
|
e.target.classList.add('fa-compress');
|
||||||
|
e.target.title = 'Hide lines';
|
||||||
|
e.target.setAttribute('aria-label', e.target.title);
|
||||||
|
|
||||||
|
block.classList.remove('hide-boring');
|
||||||
|
} else if (e.target.classList.contains('fa-compress')) {
|
||||||
|
e.target.classList.remove('fa-compress');
|
||||||
|
e.target.classList.add('fa-expand');
|
||||||
|
e.target.title = 'Show hidden lines';
|
||||||
|
e.target.setAttribute('aria-label', e.target.title);
|
||||||
|
|
||||||
|
block.classList.add('hide-boring');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (window.playpen_copyable) {
|
||||||
|
Array.from(document.querySelectorAll('pre code')).forEach(function (block) {
|
||||||
|
var pre_block = block.parentNode;
|
||||||
|
if (!pre_block.classList.contains('playpen')) {
|
||||||
|
var buttons = pre_block.querySelector(".buttons");
|
||||||
|
if (!buttons) {
|
||||||
|
buttons = document.createElement('div');
|
||||||
|
buttons.className = 'buttons';
|
||||||
|
pre_block.insertBefore(buttons, pre_block.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
var clipButton = document.createElement('button');
|
||||||
|
clipButton.className = 'fa fa-copy clip-button';
|
||||||
|
clipButton.title = 'Copy to clipboard';
|
||||||
|
clipButton.setAttribute('aria-label', clipButton.title);
|
||||||
|
clipButton.innerHTML = '<i class=\"tooltiptext\"></i>';
|
||||||
|
|
||||||
|
buttons.insertBefore(clipButton, buttons.firstChild);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process playpen code blocks
|
||||||
|
Array.from(document.querySelectorAll(".playpen")).forEach(function (pre_block) {
|
||||||
|
// Add play button
|
||||||
|
var buttons = pre_block.querySelector(".buttons");
|
||||||
|
if (!buttons) {
|
||||||
|
buttons = document.createElement('div');
|
||||||
|
buttons.className = 'buttons';
|
||||||
|
pre_block.insertBefore(buttons, pre_block.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
var runCodeButton = document.createElement('button');
|
||||||
|
runCodeButton.className = 'fa fa-play play-button';
|
||||||
|
runCodeButton.hidden = true;
|
||||||
|
runCodeButton.title = 'Run this code';
|
||||||
|
runCodeButton.setAttribute('aria-label', runCodeButton.title);
|
||||||
|
|
||||||
|
buttons.insertBefore(runCodeButton, buttons.firstChild);
|
||||||
|
runCodeButton.addEventListener('click', function (e) {
|
||||||
|
run_rust_code(pre_block);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (window.playpen_copyable) {
|
||||||
|
var copyCodeClipboardButton = document.createElement('button');
|
||||||
|
copyCodeClipboardButton.className = 'fa fa-copy clip-button';
|
||||||
|
copyCodeClipboardButton.innerHTML = '<i class="tooltiptext"></i>';
|
||||||
|
copyCodeClipboardButton.title = 'Copy to clipboard';
|
||||||
|
copyCodeClipboardButton.setAttribute('aria-label', copyCodeClipboardButton.title);
|
||||||
|
|
||||||
|
buttons.insertBefore(copyCodeClipboardButton, buttons.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
let code_block = pre_block.querySelector("code");
|
||||||
|
if (window.ace && code_block.classList.contains("editable")) {
|
||||||
|
var undoChangesButton = document.createElement('button');
|
||||||
|
undoChangesButton.className = 'fa fa-history reset-button';
|
||||||
|
undoChangesButton.title = 'Undo changes';
|
||||||
|
undoChangesButton.setAttribute('aria-label', undoChangesButton.title);
|
||||||
|
|
||||||
|
buttons.insertBefore(undoChangesButton, buttons.firstChild);
|
||||||
|
|
||||||
|
undoChangesButton.addEventListener('click', function () {
|
||||||
|
let editor = window.ace.edit(code_block);
|
||||||
|
editor.setValue(editor.originalCode);
|
||||||
|
editor.clearSelection();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
(function themes() {
|
||||||
|
var html = document.querySelector('html');
|
||||||
|
var themeToggleButton = document.getElementById('theme-toggle');
|
||||||
|
var themePopup = document.getElementById('theme-list');
|
||||||
|
var themeColorMetaTag = document.querySelector('meta[name="theme-color"]');
|
||||||
|
var stylesheets = {
|
||||||
|
ayuHighlight: document.querySelector("[href$='ayu-highlight.css']"),
|
||||||
|
tomorrowNight: document.querySelector("[href$='tomorrow-night.css']"),
|
||||||
|
highlight: document.querySelector("[href$='highlight.css']"),
|
||||||
|
};
|
||||||
|
|
||||||
|
function showThemes() {
|
||||||
|
themePopup.style.display = 'block';
|
||||||
|
themeToggleButton.setAttribute('aria-expanded', true);
|
||||||
|
themePopup.querySelector("button#" + document.body.className).focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideThemes() {
|
||||||
|
themePopup.style.display = 'none';
|
||||||
|
themeToggleButton.setAttribute('aria-expanded', false);
|
||||||
|
themeToggleButton.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_theme(theme, store = true) {
|
||||||
|
let ace_theme;
|
||||||
|
|
||||||
|
if (theme == 'coal' || theme == 'navy') {
|
||||||
|
stylesheets.ayuHighlight.disabled = true;
|
||||||
|
stylesheets.tomorrowNight.disabled = false;
|
||||||
|
stylesheets.highlight.disabled = true;
|
||||||
|
|
||||||
|
ace_theme = "ace/theme/tomorrow_night";
|
||||||
|
} else if (theme == 'ayu') {
|
||||||
|
stylesheets.ayuHighlight.disabled = false;
|
||||||
|
stylesheets.tomorrowNight.disabled = true;
|
||||||
|
stylesheets.highlight.disabled = true;
|
||||||
|
ace_theme = "ace/theme/tomorrow_night";
|
||||||
|
} else {
|
||||||
|
stylesheets.ayuHighlight.disabled = true;
|
||||||
|
stylesheets.tomorrowNight.disabled = true;
|
||||||
|
stylesheets.highlight.disabled = false;
|
||||||
|
ace_theme = "ace/theme/dawn";
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
themeColorMetaTag.content = getComputedStyle(document.body).backgroundColor;
|
||||||
|
}, 1);
|
||||||
|
|
||||||
|
if (window.ace && window.editors) {
|
||||||
|
window.editors.forEach(function (editor) {
|
||||||
|
editor.setTheme(ace_theme);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var previousTheme;
|
||||||
|
try { previousTheme = localStorage.getItem('mdbook-theme'); } catch (e) { }
|
||||||
|
if (previousTheme === null || previousTheme === undefined) { previousTheme = default_theme; }
|
||||||
|
|
||||||
|
if (store) {
|
||||||
|
try { localStorage.setItem('mdbook-theme', theme); } catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
html.classList.remove(previousTheme);
|
||||||
|
html.classList.add(theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set theme
|
||||||
|
var theme;
|
||||||
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
||||||
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
||||||
|
|
||||||
|
set_theme(theme, false);
|
||||||
|
|
||||||
|
themeToggleButton.addEventListener('click', function () {
|
||||||
|
if (themePopup.style.display === 'block') {
|
||||||
|
hideThemes();
|
||||||
|
} else {
|
||||||
|
showThemes();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
themePopup.addEventListener('click', function (e) {
|
||||||
|
var theme = e.target.id || e.target.parentElement.id;
|
||||||
|
set_theme(theme);
|
||||||
|
});
|
||||||
|
|
||||||
|
themePopup.addEventListener('focusout', function(e) {
|
||||||
|
// e.relatedTarget is null in Safari and Firefox on macOS (see workaround below)
|
||||||
|
if (!!e.relatedTarget && !themeToggleButton.contains(e.relatedTarget) && !themePopup.contains(e.relatedTarget)) {
|
||||||
|
hideThemes();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang/mdBook/issues/628
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
if (themePopup.style.display === 'block' && !themeToggleButton.contains(e.target) && !themePopup.contains(e.target)) {
|
||||||
|
hideThemes();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('keydown', function (e) {
|
||||||
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; }
|
||||||
|
if (!themePopup.contains(e.target)) { return; }
|
||||||
|
|
||||||
|
switch (e.key) {
|
||||||
|
case 'Escape':
|
||||||
|
e.preventDefault();
|
||||||
|
hideThemes();
|
||||||
|
break;
|
||||||
|
case 'ArrowUp':
|
||||||
|
e.preventDefault();
|
||||||
|
var li = document.activeElement.parentElement;
|
||||||
|
if (li && li.previousElementSibling) {
|
||||||
|
li.previousElementSibling.querySelector('button').focus();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'ArrowDown':
|
||||||
|
e.preventDefault();
|
||||||
|
var li = document.activeElement.parentElement;
|
||||||
|
if (li && li.nextElementSibling) {
|
||||||
|
li.nextElementSibling.querySelector('button').focus();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Home':
|
||||||
|
e.preventDefault();
|
||||||
|
themePopup.querySelector('li:first-child button').focus();
|
||||||
|
break;
|
||||||
|
case 'End':
|
||||||
|
e.preventDefault();
|
||||||
|
themePopup.querySelector('li:last-child button').focus();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
(function sidebar() {
|
||||||
|
var html = document.querySelector("html");
|
||||||
|
var sidebar = document.getElementById("sidebar");
|
||||||
|
var sidebarScrollBox = document.getElementById("sidebar-scrollbox");
|
||||||
|
var sidebarLinks = document.querySelectorAll('#sidebar a');
|
||||||
|
var sidebarToggleButton = document.getElementById("sidebar-toggle");
|
||||||
|
var sidebarResizeHandle = document.getElementById("sidebar-resize-handle");
|
||||||
|
var firstContact = null;
|
||||||
|
|
||||||
|
function showSidebar() {
|
||||||
|
html.classList.remove('sidebar-hidden')
|
||||||
|
html.classList.add('sidebar-visible');
|
||||||
|
Array.from(sidebarLinks).forEach(function (link) {
|
||||||
|
link.setAttribute('tabIndex', 0);
|
||||||
|
});
|
||||||
|
sidebarToggleButton.setAttribute('aria-expanded', true);
|
||||||
|
sidebar.setAttribute('aria-hidden', false);
|
||||||
|
try { localStorage.setItem('mdbook-sidebar', 'visible'); } catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var sidebarAnchorToggles = document.querySelectorAll('#sidebar a.toggle');
|
||||||
|
|
||||||
|
function toggleSection(ev) {
|
||||||
|
ev.currentTarget.parentElement.classList.toggle('expanded');
|
||||||
|
}
|
||||||
|
|
||||||
|
Array.from(sidebarAnchorToggles).forEach(function (el) {
|
||||||
|
el.addEventListener('click', toggleSection);
|
||||||
|
});
|
||||||
|
|
||||||
|
function hideSidebar() {
|
||||||
|
html.classList.remove('sidebar-visible')
|
||||||
|
html.classList.add('sidebar-hidden');
|
||||||
|
Array.from(sidebarLinks).forEach(function (link) {
|
||||||
|
link.setAttribute('tabIndex', -1);
|
||||||
|
});
|
||||||
|
sidebarToggleButton.setAttribute('aria-expanded', false);
|
||||||
|
sidebar.setAttribute('aria-hidden', true);
|
||||||
|
try { localStorage.setItem('mdbook-sidebar', 'hidden'); } catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle sidebar
|
||||||
|
sidebarToggleButton.addEventListener('click', function sidebarToggle() {
|
||||||
|
if (html.classList.contains("sidebar-hidden")) {
|
||||||
|
showSidebar();
|
||||||
|
} else if (html.classList.contains("sidebar-visible")) {
|
||||||
|
hideSidebar();
|
||||||
|
} else {
|
||||||
|
if (getComputedStyle(sidebar)['transform'] === 'none') {
|
||||||
|
hideSidebar();
|
||||||
|
} else {
|
||||||
|
showSidebar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
sidebarResizeHandle.addEventListener('mousedown', initResize, false);
|
||||||
|
|
||||||
|
function initResize(e) {
|
||||||
|
window.addEventListener('mousemove', resize, false);
|
||||||
|
window.addEventListener('mouseup', stopResize, false);
|
||||||
|
html.classList.add('sidebar-resizing');
|
||||||
|
}
|
||||||
|
function resize(e) {
|
||||||
|
document.documentElement.style.setProperty('--sidebar-width', (e.clientX - sidebar.offsetLeft) + 'px');
|
||||||
|
}
|
||||||
|
//on mouseup remove windows functions mousemove & mouseup
|
||||||
|
function stopResize(e) {
|
||||||
|
html.classList.remove('sidebar-resizing');
|
||||||
|
window.removeEventListener('mousemove', resize, false);
|
||||||
|
window.removeEventListener('mouseup', stopResize, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('touchstart', function (e) {
|
||||||
|
firstContact = {
|
||||||
|
x: e.touches[0].clientX,
|
||||||
|
time: Date.now()
|
||||||
|
};
|
||||||
|
}, { passive: true });
|
||||||
|
|
||||||
|
document.addEventListener('touchmove', function (e) {
|
||||||
|
if (!firstContact)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var curX = e.touches[0].clientX;
|
||||||
|
var xDiff = curX - firstContact.x,
|
||||||
|
tDiff = Date.now() - firstContact.time;
|
||||||
|
|
||||||
|
if (tDiff < 250 && Math.abs(xDiff) >= 150) {
|
||||||
|
if (xDiff >= 0 && firstContact.x < Math.min(document.body.clientWidth * 0.25, 300))
|
||||||
|
showSidebar();
|
||||||
|
else if (xDiff < 0 && curX < 300)
|
||||||
|
hideSidebar();
|
||||||
|
|
||||||
|
firstContact = null;
|
||||||
|
}
|
||||||
|
}, { passive: true });
|
||||||
|
|
||||||
|
// Scroll sidebar to current active section
|
||||||
|
var activeSection = sidebar.querySelector(".active");
|
||||||
|
if (activeSection) {
|
||||||
|
sidebarScrollBox.scrollTop = activeSection.offsetTop;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
(function chapterNavigation() {
|
||||||
|
document.addEventListener('keydown', function (e) {
|
||||||
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; }
|
||||||
|
if (window.search && window.search.hasFocus()) { return; }
|
||||||
|
|
||||||
|
switch (e.key) {
|
||||||
|
case 'ArrowRight':
|
||||||
|
e.preventDefault();
|
||||||
|
var nextButton = document.querySelector('.nav-chapters.next');
|
||||||
|
if (nextButton) {
|
||||||
|
window.location.href = nextButton.href;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'ArrowLeft':
|
||||||
|
e.preventDefault();
|
||||||
|
var previousButton = document.querySelector('.nav-chapters.previous');
|
||||||
|
if (previousButton) {
|
||||||
|
window.location.href = previousButton.href;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
(function clipboard() {
|
||||||
|
var clipButtons = document.querySelectorAll('.clip-button');
|
||||||
|
|
||||||
|
function hideTooltip(elem) {
|
||||||
|
elem.firstChild.innerText = "";
|
||||||
|
elem.className = 'fa fa-copy clip-button';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showTooltip(elem, msg) {
|
||||||
|
elem.firstChild.innerText = msg;
|
||||||
|
elem.className = 'fa fa-copy tooltipped';
|
||||||
|
}
|
||||||
|
|
||||||
|
var clipboardSnippets = new ClipboardJS('.clip-button', {
|
||||||
|
text: function (trigger) {
|
||||||
|
hideTooltip(trigger);
|
||||||
|
let playpen = trigger.closest("pre");
|
||||||
|
return playpen_text(playpen);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Array.from(clipButtons).forEach(function (clipButton) {
|
||||||
|
clipButton.addEventListener('mouseout', function (e) {
|
||||||
|
hideTooltip(e.currentTarget);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
clipboardSnippets.on('success', function (e) {
|
||||||
|
e.clearSelection();
|
||||||
|
showTooltip(e.trigger, "Copied!");
|
||||||
|
});
|
||||||
|
|
||||||
|
clipboardSnippets.on('error', function (e) {
|
||||||
|
showTooltip(e.trigger, "Clipboard error!");
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
(function scrollToTop () {
|
||||||
|
var menuTitle = document.querySelector('.menu-title');
|
||||||
|
|
||||||
|
menuTitle.addEventListener('click', function () {
|
||||||
|
document.scrollingElement.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
(function autoHideMenu() {
|
||||||
|
var menu = document.getElementById('menu-bar');
|
||||||
|
|
||||||
|
var previousScrollTop = document.scrollingElement.scrollTop;
|
||||||
|
|
||||||
|
document.addEventListener('scroll', function () {
|
||||||
|
if (menu.classList.contains('folded') && document.scrollingElement.scrollTop < previousScrollTop) {
|
||||||
|
menu.classList.remove('folded');
|
||||||
|
} else if (!menu.classList.contains('folded') && document.scrollingElement.scrollTop > previousScrollTop) {
|
||||||
|
menu.classList.add('folded');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!menu.classList.contains('bordered') && document.scrollingElement.scrollTop > 0) {
|
||||||
|
menu.classList.add('bordered');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu.classList.contains('bordered') && document.scrollingElement.scrollTop === 0) {
|
||||||
|
menu.classList.remove('bordered');
|
||||||
|
}
|
||||||
|
|
||||||
|
previousScrollTop = Math.max(document.scrollingElement.scrollTop, 0);
|
||||||
|
}, { passive: true });
|
||||||
|
})();
|
232
ch01-00-getting-started.html
Normal file
232
ch01-00-getting-started.html
Normal file
File diff suppressed because one or more lines are too long
315
ch01-01-installation.html
Normal file
315
ch01-01-installation.html
Normal file
File diff suppressed because one or more lines are too long
367
ch01-02-hello-world.html
Normal file
367
ch01-02-hello-world.html
Normal file
File diff suppressed because one or more lines are too long
405
ch01-03-hello-cargo.html
Normal file
405
ch01-03-hello-cargo.html
Normal file
File diff suppressed because one or more lines are too long
1023
ch02-00-guessing-game-tutorial.html
Normal file
1023
ch02-00-guessing-game-tutorial.html
Normal file
File diff suppressed because one or more lines are too long
243
ch03-00-common-programming-concepts.html
Normal file
243
ch03-00-common-programming-concepts.html
Normal file
File diff suppressed because one or more lines are too long
409
ch03-01-variables-and-mutability.html
Normal file
409
ch03-01-variables-and-mutability.html
Normal file
File diff suppressed because one or more lines are too long
554
ch03-02-data-types.html
Normal file
554
ch03-02-data-types.html
Normal file
File diff suppressed because one or more lines are too long
491
ch03-03-how-functions-work.html
Normal file
491
ch03-03-how-functions-work.html
Normal file
File diff suppressed because one or more lines are too long
263
ch03-04-comments.html
Normal file
263
ch03-04-comments.html
Normal file
File diff suppressed because one or more lines are too long
611
ch03-05-control-flow.html
Normal file
611
ch03-05-control-flow.html
Normal file
File diff suppressed because one or more lines are too long
230
ch04-00-understanding-ownership.html
Normal file
230
ch04-00-understanding-ownership.html
Normal file
File diff suppressed because one or more lines are too long
709
ch04-01-what-is-ownership.html
Normal file
709
ch04-01-what-is-ownership.html
Normal file
File diff suppressed because one or more lines are too long
511
ch04-02-references-and-borrowing.html
Normal file
511
ch04-02-references-and-borrowing.html
Normal file
File diff suppressed because one or more lines are too long
559
ch04-03-slices.html
Normal file
559
ch04-03-slices.html
Normal file
File diff suppressed because one or more lines are too long
234
ch05-00-structs.html
Normal file
234
ch05-00-structs.html
Normal file
File diff suppressed because one or more lines are too long
513
ch05-01-defining-structs.html
Normal file
513
ch05-01-defining-structs.html
Normal file
File diff suppressed because one or more lines are too long
423
ch05-02-example-structs.html
Normal file
423
ch05-02-example-structs.html
Normal file
File diff suppressed because one or more lines are too long
468
ch05-03-method-syntax.html
Normal file
468
ch05-03-method-syntax.html
Normal file
File diff suppressed because one or more lines are too long
237
ch06-00-enums.html
Normal file
237
ch06-00-enums.html
Normal file
File diff suppressed because one or more lines are too long
598
ch06-01-defining-an-enum.html
Normal file
598
ch06-01-defining-an-enum.html
Normal file
File diff suppressed because one or more lines are too long
486
ch06-02-match.html
Normal file
486
ch06-02-match.html
Normal file
File diff suppressed because one or more lines are too long
336
ch06-03-if-let.html
Normal file
336
ch06-03-if-let.html
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
275
ch07-01-packages-and-crates.html
Normal file
275
ch07-01-packages-and-crates.html
Normal file
File diff suppressed because one or more lines are too long
311
ch07-02-defining-modules-to-control-scope-and-privacy.html
Normal file
311
ch07-02-defining-modules-to-control-scope-and-privacy.html
Normal file
File diff suppressed because one or more lines are too long
536
ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html
Normal file
536
ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html
Normal file
File diff suppressed because one or more lines are too long
540
ch07-04-bringing-paths-into-scope-with-the-use-keyword.html
Normal file
540
ch07-04-bringing-paths-into-scope-with-the-use-keyword.html
Normal file
File diff suppressed because one or more lines are too long
291
ch07-05-separating-modules-into-different-files.html
Normal file
291
ch07-05-separating-modules-into-different-files.html
Normal file
File diff suppressed because one or more lines are too long
245
ch08-00-common-collections.html
Normal file
245
ch08-00-common-collections.html
Normal file
File diff suppressed because one or more lines are too long
486
ch08-01-vectors.html
Normal file
486
ch08-01-vectors.html
Normal file
File diff suppressed because one or more lines are too long
612
ch08-02-strings.html
Normal file
612
ch08-02-strings.html
Normal file
File diff suppressed because one or more lines are too long
500
ch08-03-hash-maps.html
Normal file
500
ch08-03-hash-maps.html
Normal file
File diff suppressed because one or more lines are too long
245
ch09-00-error-handling.html
Normal file
245
ch09-00-error-handling.html
Normal file
File diff suppressed because one or more lines are too long
390
ch09-01-unrecoverable-errors-with-panic.html
Normal file
390
ch09-01-unrecoverable-errors-with-panic.html
Normal file
File diff suppressed because one or more lines are too long
673
ch09-02-recoverable-errors-with-result.html
Normal file
673
ch09-02-recoverable-errors-with-result.html
Normal file
File diff suppressed because one or more lines are too long
439
ch09-03-to-panic-or-not-to-panic.html
Normal file
439
ch09-03-to-panic-or-not-to-panic.html
Normal file
File diff suppressed because one or more lines are too long
371
ch10-00-generics.html
Normal file
371
ch10-00-generics.html
Normal file
File diff suppressed because one or more lines are too long
616
ch10-01-syntax.html
Normal file
616
ch10-01-syntax.html
Normal file
File diff suppressed because one or more lines are too long
744
ch10-02-traits.html
Normal file
744
ch10-02-traits.html
Normal file
File diff suppressed because one or more lines are too long
869
ch10-03-lifetime-syntax.html
Normal file
869
ch10-03-lifetime-syntax.html
Normal file
File diff suppressed because one or more lines are too long
253
ch11-00-testing.html
Normal file
253
ch11-00-testing.html
Normal file
File diff suppressed because one or more lines are too long
912
ch11-01-writing-tests.html
Normal file
912
ch11-01-writing-tests.html
Normal file
File diff suppressed because one or more lines are too long
482
ch11-02-running-tests.html
Normal file
482
ch11-02-running-tests.html
Normal file
File diff suppressed because one or more lines are too long
495
ch11-03-test-organization.html
Normal file
495
ch11-03-test-organization.html
Normal file
File diff suppressed because one or more lines are too long
260
ch12-00-an-io-project.html
Normal file
260
ch12-00-an-io-project.html
Normal file
File diff suppressed because one or more lines are too long
345
ch12-01-accepting-command-line-arguments.html
Normal file
345
ch12-01-accepting-command-line-arguments.html
Normal file
File diff suppressed because one or more lines are too long
305
ch12-02-reading-a-file.html
Normal file
305
ch12-02-reading-a-file.html
Normal file
File diff suppressed because one or more lines are too long
777
ch12-03-improving-error-handling-and-modularity.html
Normal file
777
ch12-03-improving-error-handling-and-modularity.html
Normal file
File diff suppressed because one or more lines are too long
495
ch12-04-testing-the-librarys-functionality.html
Normal file
495
ch12-04-testing-the-librarys-functionality.html
Normal file
File diff suppressed because one or more lines are too long
495
ch12-05-working-with-environment-variables.html
Normal file
495
ch12-05-working-with-environment-variables.html
Normal file
File diff suppressed because one or more lines are too long
312
ch12-06-writing-to-stderr-instead-of-stdout.html
Normal file
312
ch12-06-writing-to-stderr-instead-of-stdout.html
Normal file
File diff suppressed because one or more lines are too long
245
ch13-00-functional-features.html
Normal file
245
ch13-00-functional-features.html
Normal file
File diff suppressed because one or more lines are too long
941
ch13-01-closures.html
Normal file
941
ch13-01-closures.html
Normal file
File diff suppressed because one or more lines are too long
659
ch13-02-iterators.html
Normal file
659
ch13-02-iterators.html
Normal file
File diff suppressed because one or more lines are too long
414
ch13-03-improving-our-io-project.html
Normal file
414
ch13-03-improving-our-io-project.html
Normal file
File diff suppressed because one or more lines are too long
304
ch13-04-performance.html
Normal file
304
ch13-04-performance.html
Normal file
File diff suppressed because one or more lines are too long
238
ch14-00-more-about-cargo.html
Normal file
238
ch14-00-more-about-cargo.html
Normal file
File diff suppressed because one or more lines are too long
274
ch14-01-release-profiles.html
Normal file
274
ch14-01-release-profiles.html
Normal file
File diff suppressed because one or more lines are too long
624
ch14-02-publishing-to-crates-io.html
Normal file
624
ch14-02-publishing-to-crates-io.html
Normal file
File diff suppressed because one or more lines are too long
494
ch14-03-cargo-workspaces.html
Normal file
494
ch14-03-cargo-workspaces.html
Normal file
File diff suppressed because one or more lines are too long
254
ch14-04-installing-binaries.html
Normal file
254
ch14-04-installing-binaries.html
Normal file
File diff suppressed because one or more lines are too long
238
ch14-05-extending-cargo.html
Normal file
238
ch14-05-extending-cargo.html
Normal file
File diff suppressed because one or more lines are too long
273
ch15-00-smart-pointers.html
Normal file
273
ch15-00-smart-pointers.html
Normal file
File diff suppressed because one or more lines are too long
451
ch15-01-box.html
Normal file
451
ch15-01-box.html
Normal file
File diff suppressed because one or more lines are too long
541
ch15-02-deref.html
Normal file
541
ch15-02-deref.html
Normal file
File diff suppressed because one or more lines are too long
373
ch15-03-drop.html
Normal file
373
ch15-03-drop.html
Normal file
File diff suppressed because one or more lines are too long
401
ch15-04-rc.html
Normal file
401
ch15-04-rc.html
Normal file
File diff suppressed because one or more lines are too long
669
ch15-05-interior-mutability.html
Normal file
669
ch15-05-interior-mutability.html
Normal file
File diff suppressed because one or more lines are too long
648
ch15-06-reference-cycles.html
Normal file
648
ch15-06-reference-cycles.html
Normal file
File diff suppressed because one or more lines are too long
271
ch16-00-concurrency.html
Normal file
271
ch16-00-concurrency.html
Normal file
File diff suppressed because one or more lines are too long
554
ch16-01-threads.html
Normal file
554
ch16-01-threads.html
Normal file
File diff suppressed because one or more lines are too long
523
ch16-02-message-passing.html
Normal file
523
ch16-02-message-passing.html
Normal file
File diff suppressed because one or more lines are too long
585
ch16-03-shared-state.html
Normal file
585
ch16-03-shared-state.html
Normal file
File diff suppressed because one or more lines are too long
291
ch16-04-extensible-concurrency-sync-and-send.html
Normal file
291
ch16-04-extensible-concurrency-sync-and-send.html
Normal file
File diff suppressed because one or more lines are too long
236
ch17-00-oop.html
Normal file
236
ch17-00-oop.html
Normal file
File diff suppressed because one or more lines are too long
386
ch17-01-what-is-oo.html
Normal file
386
ch17-01-what-is-oo.html
Normal file
File diff suppressed because one or more lines are too long
594
ch17-02-trait-objects.html
Normal file
594
ch17-02-trait-objects.html
Normal file
File diff suppressed because one or more lines are too long
875
ch17-03-oo-design-patterns.html
Normal file
875
ch17-03-oo-design-patterns.html
Normal file
File diff suppressed because one or more lines are too long
249
ch18-00-patterns.html
Normal file
249
ch18-00-patterns.html
Normal file
File diff suppressed because one or more lines are too long
456
ch18-01-all-the-places-for-patterns.html
Normal file
456
ch18-01-all-the-places-for-patterns.html
Normal file
File diff suppressed because one or more lines are too long
309
ch18-02-refutability.html
Normal file
309
ch18-02-refutability.html
Normal file
File diff suppressed because one or more lines are too long
934
ch18-03-pattern-syntax.html
Normal file
934
ch18-03-pattern-syntax.html
Normal file
File diff suppressed because one or more lines are too long
244
ch19-00-advanced-features.html
Normal file
244
ch19-00-advanced-features.html
Normal file
File diff suppressed because one or more lines are too long
693
ch19-01-unsafe-rust.html
Normal file
693
ch19-01-unsafe-rust.html
Normal file
File diff suppressed because one or more lines are too long
813
ch19-03-advanced-traits.html
Normal file
813
ch19-03-advanced-traits.html
Normal file
File diff suppressed because one or more lines are too long
528
ch19-04-advanced-types.html
Normal file
528
ch19-04-advanced-types.html
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user