Skip to content

Commit b61c8e5

Browse files
pickfireAndyGauge
andauthored
Update to edition 2018 (#565)
* Update to edition 2018 Update mdbook to 0.3.5 Command: sed -i '/extern crate/ {N;s/\n$//}' src/**.md; sed -i 's/extern crate error_chain;/use error_chain::error_chain;/; s/extern crate lazy_static;/use lazy_static::lazy_static;/; s/extern crate bitflags;/use bitflags::bitflags;/; s/extern crate serde_json;/ use serde_json::json;/; s/extern crate serde_derive;/use serde::{Serialize, Deserialize};/; /macro_use/d; /extern crate/ d; s/```rust/```rust,edition2018/; s/bail!/error_chain::&/; s/\(debug\|info\|warn\|error\)!/log::&/;' src/**.md Fix #530 * Update rand-dist.md * Fixes #569 * dump syslog version 4 depends on error-chain v 0.11 and version 5 depends on v 0.12 !!!! Co-authored-by: Andrew Gauger <[email protected]>
1 parent 7a06c79 commit b61c8e5

File tree

145 files changed

+256
-809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+256
-809
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cd rust-cookbook
2020
Cookbook is built with [mdBook], so install that first with Cargo:
2121

2222
```
23-
cargo install --version 0.1.8 mdbook
23+
cargo install --version 0.3.5 mdbook
2424
```
2525

2626
To build and view the cookbook locally, run:

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
name = "rust-cookbook"
33
version = "0.1.0"
44
authors = ["Brian Anderson <[email protected]>"]
5+
edition = "2018"
56
license = "MIT/Apache-2.0"
67
publish = false
78

89
build = "build.rs"
910

1011
[dependencies]
1112
ansi_term = "0.11.0"
13+
approx = "0.3"
1214
base64 = "0.9"
1315
bitflags = "1.0"
1416
byteorder = "1.0"
@@ -58,7 +60,7 @@ url = "2.1"
5860
walkdir = "2.0"
5961

6062
[target.'cfg(target_os = "linux")'.dependencies]
61-
syslog = "4.0"
63+
syslog = "5.0"
6264

6365
[build-dependencies]
6466
skeptic = "0.13"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If you'd like to read it locally:
1919
```bash
2020
$ git clone https://github.com/rust-lang-nursery/rust-cookbook
2121
$ cd rust-cookbook
22-
$ cargo install mdbook --vers "0.1.8"
22+
$ cargo install mdbook --vers "0.3.5"
2323
$ mdbook serve --open
2424
```
2525

book.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
title = "Rust Cookbook"
44
description = "Collection of useful Rust code examples"
55
authors = ["Rust Language Community"]
6+
edition = "2018"
67
multilingual = false
8+
language = "en"
79
src = "src"
810

911
[output.html]
1012
mathjax-support = false
11-
theme = "theme"
13+
# theme = "theme"
1214
additional-css = ["theme/custom.css"]
1315

1416
[output.html.playpen]

ci/install_deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if [[ "${CONTENT_TESTS:-}" == 1 ]]; then
1818
pyenv local 3.6.0
1919
pip3 install --user link-checker==0.1.0
2020
fi
21-
cargo install mdbook --vers '0.1.8' --debug
21+
cargo install mdbook --vers '0.3.5' --debug
2222
fi
2323

2424
exit 0

src/about.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ Consider this example for "generate random numbers within a range":
5656

5757
[![rand-badge]][rand] [![cat-science-badge]][cat-science]
5858

59-
```rust
60-
extern crate rand;
59+
```rust,edition2018
6160
use rand::Rng;
6261
6362
fn main() {
@@ -111,10 +110,8 @@ The basic pattern we use is to have a `fn main() -> Result`.
111110

112111
The structure generally looks like:
113112

114-
```rust
115-
#[macro_use]
116-
extern crate error_chain;
117-
113+
```rust,edition2018
114+
use error_chain::error_chain;
118115
use std::net::IpAddr;
119116
use std::str;
120117
@@ -150,10 +147,8 @@ default like below. In order to read full contents click on the
150147
"expand" (<i class="fa fa-expand"></i>) button located in the top
151148
right corner of the snippet.
152149

153-
```rust
154-
# #[macro_use]
155-
# extern crate error_chain;
156-
extern crate url;
150+
```rust,edition2018
151+
# use error_chain::error_chain;
157152
158153
use url::{Url, Position};
159154
#

src/algorithms/randomness/rand-choose.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
Randomly generates a string of given length ASCII characters with custom
66
user-defined bytestring, with [`gen_range`].
77

8-
```rust
9-
extern crate rand;
10-
8+
```rust,edition2018
119
fn main() {
1210
use rand::Rng;
1311
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\

src/algorithms/randomness/rand-custom.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
Randomly generates a tuple `(i32, bool, f64)` and variable of user defined type `Point`.
66
Implements the [`Distribution`] trait on type Point for [`Standard`] in order to allow random generation.
77

8-
```rust,ignore
9-
extern crate rand;
10-
8+
```rust,edition2018,ignore
119
use rand::Rng;
1210
use rand::distributions::{Distribution, Standard};
1311

src/algorithms/randomness/rand-dist.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ generator [`rand::Rng`].
1212
The [distributions available are documented here][rand-distributions].
1313
An example using the [`Normal`] distribution is shown below.
1414

15-
```rust,ignore
16-
extern crate rand_distr;
17-
extern crate rand;
18-
15+
```rust,edition2018,ignore
1916
use rand_distr::{Distribution, Normal, NormalError};
2017
2118
fn main() -> Result<(), NormalError> {

src/algorithms/randomness/rand-passwd.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
Randomly generates a string of given length ASCII characters in the range `A-Z,
66
a-z, 0-9`, with [`Alphanumeric`] sample.
77

8-
```rust,ignore
9-
extern crate rand;
10-
8+
```rust,edition2018,ignore
119
use rand::{thread_rng, Rng};
1210
use rand::distributions::Alphanumeric;
1311

0 commit comments

Comments
 (0)