mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 19:54:34 -06:00
rebuild pages at 6b022d6
This commit is contained in:
@@ -87,7 +87,9 @@ fn concat_files(source_paths: Vec<PathBuf>, target_path: PathBuf) -> io::Result<
|
||||
let mut contents: Vec<u8> = Vec::new();
|
||||
try!(source.read_to_end(&mut contents));
|
||||
|
||||
if !is_first {
|
||||
if is_first {
|
||||
try!(target.write_all(b"\n[TOC]\n\n"));
|
||||
} else {
|
||||
try!(target.write_all(b"\n"));
|
||||
}
|
||||
try!(target.write_all(&contents));
|
||||
|
||||
+5
-5
@@ -39,12 +39,12 @@ fn parse_references(buffer: String) -> (String, HashMap<String, String>) {
|
||||
|
||||
fn parse_links((buffer, ref_map): (String, HashMap<String, String>)) -> String {
|
||||
// TODO: check which punctuation is allowed by spec
|
||||
let re = Regex::new(r###"(?:(?P<pre>(?:```(?:[^`]|`[^`])*`?\n```\n)|(?:[^[]`[^`\n]+[\n]?[^`\n]*`))|(?:\[(?P<name>[^]]+)\](?:(?:\([[:blank:]]*(?P<val>[^")]*[^ ])(?:[[:blank:]]*"[^"]*")?\))|(?:\[(?P<key>[^]]*)\]))?))"###).unwrap();
|
||||
let re = Regex::new(r###"(?:(?P<pre>(?:```(?:[^`]|`[^`])*`?\n```\n)|(?:[^[]`[^`\n]+[\n]?[^`\n]*`))|(?:\[(?P<name>[^]]+)\](?:(?:\([[:blank:]]*(?P<val>[^")]*[^ ])(?:[[:blank:]]*"[^"]*")?\))|(?:\[(?P<key>[^]]*)\]))?))"###).expect("could not create regex");
|
||||
let output = re.replace_all(&buffer, |caps: &Captures| {
|
||||
match caps.name("pre") {
|
||||
Some(pre_section) => format!("{}", pre_section.to_owned()),
|
||||
None => {
|
||||
let name = caps.name("name").unwrap().to_owned();
|
||||
let name = caps.name("name").expect("could not get name").to_owned();
|
||||
let val = match caps.name("val") {
|
||||
// [name](link)
|
||||
Some(value) => value.to_owned(),
|
||||
@@ -53,13 +53,13 @@ fn parse_links((buffer, ref_map): (String, HashMap<String, String>)) -> String {
|
||||
Some(key) => {
|
||||
match key {
|
||||
// [name][]
|
||||
"" => format!("{}", ref_map.get(&name.to_uppercase()).unwrap()),
|
||||
"" => format!("{}", ref_map.get(&name.to_uppercase()).expect(&format!("could not find url for the link text `{}`", name))),
|
||||
// [name][reference]
|
||||
_ => format!("{}", ref_map.get(&key.to_uppercase()).unwrap()),
|
||||
_ => format!("{}", ref_map.get(&key.to_uppercase()).expect(&format!("could not find url for the link text `{}`", key))),
|
||||
}
|
||||
}
|
||||
// [name] as reference
|
||||
None => format!("{}", ref_map.get(&name.to_uppercase()).unwrap()),
|
||||
None => format!("{}", ref_map.get(&name.to_uppercase()).expect(&format!("could not find url for the link text `{}`", name))),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,8 +67,7 @@
|
||||
</div>
|
||||
|
||||
<div id="content" class="content">
|
||||
<p>[TOC]</p>
|
||||
<h1>Guessing Game</h1>
|
||||
<h1>Guessing Game</h1>
|
||||
<p>Let's jump into Rust with a hands-on project! This chapter will introduce you to
|
||||
a few common Rust concepts by showing how you would use them in a real program.
|
||||
You'll learn about <code>let</code>, <code>match</code>, methods, associated functions, using
|
||||
|
||||
@@ -268,9 +268,9 @@ copying can be assumed to be inexpensive.</p>
|
||||
<h3>Clone</h3>
|
||||
<p>But what if we <em>do</em> want to deeply copy the <code>String</code>’s data and not just the
|
||||
<code>String</code> itself? There’s a common method for that: <code>clone()</code>. We will discuss
|
||||
methods in the section on [<code>structs</code> in Chapter XX], but they’re a common
|
||||
enough feature in many programming languages that you have probably seen them
|
||||
before.</p>
|
||||
methods in the section on <a href="ch05-01-structs.html"><code>structs</code> in Chapter XX</a>, but they’re a
|
||||
common enough feature in many programming languages that you have probably seen
|
||||
them before.</p>
|
||||
<p>Here’s an example of the <code>clone()</code> method in action:</p>
|
||||
<pre><code class="language-rust">let s1 = String::from("hello");
|
||||
let s2 = s1.clone();
|
||||
|
||||
@@ -74,8 +74,8 @@ the same Cargo.lock and output directory.</p>
|
||||
<em>crate</em> until now, and casually people will use the words <em>package</em> and <em>crate</em>
|
||||
interchangeably and everyone will understand.</p>
|
||||
<p>But there are cases when it makes sense to have multiple crates in one project
|
||||
because [insert reasons here]. For example, [insert examples here, maybe
|
||||
log/env_log in rust-lang-nursery?]</p>
|
||||
because (insert reasons here). For example, (insert examples here, maybe
|
||||
log/env_log in rust-lang-nursery?)</p>
|
||||
<p>So let's get more precise now. Earlier, we said:</p>
|
||||
<blockquote>
|
||||
<p>A <em>crate</em> is what we call a package of Rust code.</p>
|
||||
|
||||
+5
-6
@@ -436,7 +436,6 @@ $ cargo build
|
||||
<p>Note: If you want to look at Cargo in more detail, check out the official
|
||||
<a href="http://doc.crates.io/guide.html">Cargo guide</a>, which covers all of its features.</p>
|
||||
</blockquote>
|
||||
<p>[TOC]</p>
|
||||
<h1>Guessing Game</h1>
|
||||
<p>Let's jump into Rust with a hands-on project! This chapter will introduce you to
|
||||
a few common Rust concepts by showing how you would use them in a real program.
|
||||
@@ -2499,9 +2498,9 @@ copying can be assumed to be inexpensive.</p>
|
||||
<h3>Clone</h3>
|
||||
<p>But what if we <em>do</em> want to deeply copy the <code>String</code>’s data and not just the
|
||||
<code>String</code> itself? There’s a common method for that: <code>clone()</code>. We will discuss
|
||||
methods in the section on [<code>structs</code> in Chapter XX], but they’re a common
|
||||
enough feature in many programming languages that you have probably seen them
|
||||
before.</p>
|
||||
methods in the section on <a href="ch05-01-structs.html"><code>structs</code> in Chapter XX</a>, but they’re a
|
||||
common enough feature in many programming languages that you have probably seen
|
||||
them before.</p>
|
||||
<p>Here’s an example of the <code>clone()</code> method in action:</p>
|
||||
<pre><code class="language-rust">let s1 = String::from("hello");
|
||||
let s2 = s1.clone();
|
||||
@@ -4436,8 +4435,8 @@ the same Cargo.lock and output directory.</p>
|
||||
<em>crate</em> until now, and casually people will use the words <em>package</em> and <em>crate</em>
|
||||
interchangeably and everyone will understand.</p>
|
||||
<p>But there are cases when it makes sense to have multiple crates in one project
|
||||
because [insert reasons here]. For example, [insert examples here, maybe
|
||||
log/env_log in rust-lang-nursery?]</p>
|
||||
because (insert reasons here). For example, (insert examples here, maybe
|
||||
log/env_log in rust-lang-nursery?)</p>
|
||||
<p>So let's get more precise now. Earlier, we said:</p>
|
||||
<blockquote>
|
||||
<p>A <em>crate</em> is what we call a package of Rust code.</p>
|
||||
|
||||
Reference in New Issue
Block a user