Skip to content

Commit e0f9824

Browse files
committed
Hide non essential parts of snippets by default
Updated net.md to hide error_chain boilerplate by default it can be exposed by selecting the "expand button" The expand button is no longer hidden
1 parent 4a5c675 commit e0f9824

File tree

2 files changed

+111
-112
lines changed

2 files changed

+111
-112
lines changed

src/net.md

+110-111
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ URL will print a message containing an explanation of what went wrong.
3030

3131
```rust
3232
extern crate url;
33-
34-
#[macro_use]
35-
extern crate error_chain;
33+
#
34+
# #[macro_use]
35+
# extern crate error_chain;
3636

3737
use url::Url;
38-
39-
error_chain! {
40-
foreign_links {
41-
UrlParse(url::ParseError);
42-
}
43-
}
38+
#
39+
# error_chain! {
40+
# foreign_links {
41+
# UrlParse(url::ParseError);
42+
# }
43+
# }
4444

4545
fn run() -> Result<()> {
4646
let s = "https://github.com/rust-lang/rust/issues?labels=E-easy&state=open";
@@ -50,8 +50,8 @@ fn run() -> Result<()> {
5050

5151
Ok(())
5252
}
53-
54-
quick_main!(run);
53+
#
54+
# quick_main!(run); // fn main()
5555
```
5656

5757
[ex-url-base]: #ex-url-base
@@ -64,18 +64,18 @@ quick_main!(run);
6464
extern crate url;
6565

6666
use url::Url;
67-
68-
#[macro_use]
69-
extern crate error_chain;
70-
71-
error_chain! {
72-
foreign_links {
73-
UrlParse(url::ParseError);
74-
}
75-
errors {
76-
CannotBeABase
77-
}
78-
}
67+
#
68+
# #[macro_use]
69+
# extern crate error_chain;
70+
#
71+
# error_chain! {
72+
# foreign_links {
73+
# UrlParse(url::ParseError);
74+
# }
75+
# errors {
76+
# CannotBeABase
77+
# }
78+
# }
7979

8080
fn run() -> Result<()> {
8181
let full = "https://github.com/rust-lang/cargo?asdf";
@@ -108,8 +108,8 @@ fn base_url(mut url: Url) -> Result<Url> {
108108

109109
Ok(url)
110110
}
111-
112-
quick_main!(run);
111+
#
112+
# quick_main!(run); // fn main()
113113
```
114114

115115
[ex-url-new-from-base]: #ex-url-new-from-base
@@ -122,17 +122,17 @@ The [`join`] method creates a new URL from a base and relative path.
122122

123123
```rust
124124
extern crate url;
125-
126-
#[macro_use]
127-
extern crate error_chain;
125+
#
126+
# #[macro_use]
127+
# extern crate error_chain;
128128

129129
use url::Url;
130-
131-
error_chain! {
132-
foreign_links {
133-
UrlParse(url::ParseError);
134-
}
135-
}
130+
#
131+
# error_chain! {
132+
# foreign_links {
133+
# UrlParse(url::ParseError);
134+
# }
135+
# }
136136

137137
fn run() -> Result<()> {
138138
let path = "/rust-lang/cargo";
@@ -154,8 +154,8 @@ fn build_github_url(path: &str) -> Result<Url> {
154154

155155
Ok(joined)
156156
}
157-
158-
quick_main!(run);
157+
#
158+
# quick_main!(run); // fn main()
159159
```
160160

161161
[ex-url-origin]: #ex-url-origin
@@ -170,16 +170,16 @@ it represents.
170170
```rust
171171
extern crate url;
172172

173-
#[macro_use]
174-
extern crate error_chain;
173+
# #[macro_use]
174+
# extern crate error_chain;
175175

176176
use url::{Url, Host};
177177

178-
error_chain! {
179-
foreign_links {
180-
UrlParse(url::ParseError);
181-
}
182-
}
178+
# error_chain! {
179+
# foreign_links {
180+
# UrlParse(url::ParseError);
181+
# }
182+
# }
183183

184184
fn run() -> Result<()> {
185185
let s = "ftp://rust-lang.org/examples";
@@ -193,26 +193,26 @@ fn run() -> Result<()> {
193193

194194
Ok(())
195195
}
196-
197-
quick_main!(run);
196+
#
197+
# quick_main!(run); // fn main()
198198
```
199199

200200
The same result can be obtained using the [`origin`] method as well.
201201

202202
```rust
203203
extern crate url;
204204

205-
#[macro_use]
206-
extern crate error_chain;
207-
205+
# #[macro_use]
206+
# extern crate error_chain;
207+
#
208208
use url::{Url, Origin, Host};
209209

210-
error_chain! {
211-
foreign_links {
212-
UrlParse(url::ParseError);
213-
}
214-
}
215-
210+
# error_chain! {
211+
# foreign_links {
212+
# UrlParse(url::ParseError);
213+
# }
214+
# }
215+
#
216216
fn run() -> Result<()> {
217217
let s = "ftp://rust-lang.org/examples";
218218

@@ -229,8 +229,8 @@ fn run() -> Result<()> {
229229

230230
Ok(())
231231
}
232-
233-
quick_main!(run);
232+
#
233+
# quick_main!(run); // fn main()
234234
```
235235

236236
[ex-url-rm-frag]: #ex-url-rm-frag
@@ -243,26 +243,26 @@ Once [`Url`] is parsed it can be sliced with [`url::Position`] to strip unneeded
243243

244244
```rust
245245
extern crate url;
246-
247-
#[macro_use]
248-
extern crate error_chain;
246+
#
247+
# #[macro_use]
248+
# extern crate error_chain;
249249

250250
use url::{Url, Position};
251-
252-
error_chain! {
253-
foreign_links {
254-
UrlParse(url::ParseError);
255-
}
256-
}
251+
#
252+
# error_chain! {
253+
# foreign_links {
254+
# UrlParse(url::ParseError);
255+
# }
256+
# }
257257

258258
fn run() -> Result<()> {
259259
let parsed = Url::parse("https://github.com/rust-lang/rust/issues?labels=E-easy&state=open")?;
260260
let cleaned: &str = &parsed[..Position::AfterPath];
261261
println!("cleaned: {}", cleaned);
262262
Ok(())
263263
}
264-
265-
quick_main!(run);
264+
#
265+
# quick_main!(run); // fn main()
266266
```
267267

268268
[ex-url-basic]: #ex-url-basic
@@ -277,17 +277,17 @@ status and headers are printed. HTTP response body is read into an allocated [`S
277277

278278
```rust,no_run
279279
extern crate reqwest;
280-
#[macro_use]
281-
extern crate error_chain;
280+
# #[macro_use]
281+
# extern crate error_chain;
282282
283283
use std::io::Read;
284284
285-
error_chain! {
286-
foreign_links {
287-
Io(std::io::Error);
288-
HttpReqest(reqwest::Error);
289-
}
290-
}
285+
# error_chain! {
286+
# foreign_links {
287+
# Io(std::io::Error);
288+
# HttpReqest(reqwest::Error);
289+
# }
290+
# }
291291
292292
fn run() -> Result<()> {
293293
let mut res = reqwest::get("http://httpbin.org/get")?;
@@ -300,8 +300,8 @@ fn run() -> Result<()> {
300300
301301
Ok(())
302302
}
303-
304-
quick_main!(run);
303+
#
304+
# quick_main!(run); // fn main()
305305
```
306306

307307
[ex-url-download]: #ex-url-download
@@ -316,21 +316,21 @@ Target [`File`] with name obtained from [`Response::url`] is created within [`Te
316316
and downloaded data is copied into it with [`io::copy`]. The temporary directory is implicitly removed on `run` function return.
317317

318318
```rust,no_run
319-
#[macro_use]
320-
extern crate error_chain;
319+
# #[macro_use]
320+
# extern crate error_chain;
321321
extern crate reqwest;
322322
extern crate tempdir;
323323
324324
use std::io::copy;
325325
use std::fs::File;
326326
use tempdir::TempDir;
327-
328-
error_chain! {
329-
foreign_links {
330-
Io(std::io::Error);
331-
HttpReqest(reqwest::Error);
332-
}
333-
}
327+
#
328+
# error_chain! {
329+
# foreign_links {
330+
# Io(std::io::Error);
331+
# HttpReqest(reqwest::Error);
332+
# }
333+
# }
334334
335335
fn run() -> Result<()> {
336336
// create a temp dir with prefix "example"
@@ -358,8 +358,8 @@ fn run() -> Result<()> {
358358
// tmp_dir is implicitly removed
359359
Ok(())
360360
}
361-
362-
quick_main!(run);
361+
#
362+
# quick_main!(run); // fn main()
363363
```
364364

365365
[ex-rest-get]: #ex-rest-get
@@ -374,22 +374,22 @@ GitHub [stargazers API v3](https://developer.github.com/v3/activity/starring/#li
374374
#[macro_use]
375375
extern crate serde_derive;
376376
extern crate reqwest;
377-
378-
#[macro_use]
379-
extern crate error_chain;
377+
#
378+
# #[macro_use]
379+
# extern crate error_chain;
380380
381381
#[derive(Deserialize, Debug)]
382382
struct User {
383383
login: String,
384384
id: u32,
385385
// remaining fields not deserialized for brevity
386386
}
387-
388-
error_chain! {
389-
foreign_links {
390-
Reqwest(reqwest::Error);
391-
}
392-
}
387+
#
388+
# error_chain! {
389+
# foreign_links {
390+
# Reqwest(reqwest::Error);
391+
# }
392+
# }
393393
394394
fn run() -> Result<()> {
395395
let request_url = format!("https://api.github.com/repos/{owner}/{repo}/stargazers",
@@ -402,8 +402,8 @@ fn run() -> Result<()> {
402402
println!("{:?}", users);
403403
Ok(())
404404
}
405-
406-
quick_main!(run);
405+
#
406+
# quick_main!(run); // fn main()
407407
```
408408

409409
[ex-rest-post]: #ex-rest-post
@@ -425,18 +425,17 @@ extern crate reqwest;
425425
extern crate serde_derive;
426426
#[macro_use]
427427
extern crate serde_json;
428-
429-
#[macro_use]
430-
extern crate error_chain;
428+
# #[macro_use]
429+
# extern crate error_chain;
431430
432431
use std::env;
433-
434-
error_chain! {
435-
foreign_links {
436-
EnvVar(env::VarError);
437-
HttpReqest(reqwest::Error);
438-
}
439-
}
432+
#
433+
# error_chain! {
434+
# foreign_links {
435+
# EnvVar(env::VarError);
436+
# HttpReqest(reqwest::Error);
437+
# }
438+
# }
440439
441440
#[derive(Deserialize, Debug)]
442441
struct Gist {
@@ -482,8 +481,8 @@ fn run() -> Result<()> {
482481
println!("Gist {} deleted! Status code: {}",gist.id, response.status());
483482
Ok(())
484483
}
485-
486-
quick_main!(run);
484+
#
485+
# quick_main!(run); // fn main()
487486
```
488487

489488
<!-- Categories -->

theme/book.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,6 @@ table td:nth-child(2){
833833
width: 20%;
834834
}
835835

836-
pre > .buttons {
836+
i.fa.fa-play.play-button {
837837
display: none;
838838
}

0 commit comments

Comments
 (0)