From 16a043b09ac5cb997df474534bf19be0146f1523 Mon Sep 17 00:00:00 2001 From: Jubilee <46493976+workingjubilee@users.noreply.github.com> Date: Thu, 19 Sep 2019 11:04:37 -0700 Subject: [PATCH 1/4] Update inclusive range syntax, fix script pathname, crate deps (#547) Fix docs directing developer to incorrect pathname for spellcheck.sh Add note on the normal behavior of spellcheck.sh for clarity Fix instances of inclusive range syntax to use '..=' style Depend directly on percent-encoding instead of expecting re-exports This commit compiles and tests correctly on rustc v1.37.0 link-checker found 452 failures before this commit link-checker found 452 failures after this commit no new errors were added by this commit --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- CONTRIBUTING.md | 6 ++++-- Cargo.toml | 3 ++- src/concurrency/thread/threadpool-fractal.md | 16 ++++++++-------- src/encoding/string/percent-encode.md | 13 ++++++++----- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 7a9abe2..8561e7f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,7 +12,7 @@ No worries if anything in these lists is unclear. Just submit the PR and ask awa - [ ] commits are squashed into one and rebased to latest master - [ ] PR contains correct "fixes #ISSUE_ID" clause to autoclose the issue on PR merge - if issue does not exist consider creating it or remove the clause -- [ ] spell check runs without errors `./ci/spellchecker.sh` +- [ ] spell check runs without errors `./ci/spellcheck.sh` - [ ] link check runs without errors `link-checker ./book` - [ ] non rendered items are in sorted order (links, reference, identifiers, Cargo.toml) - [ ] links to docs.rs have wildcard version `https://docs.rs/tar/*/tar/struct.Entry.html` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 94560a9..f3c67e1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,10 +89,10 @@ To check the spelling of the Rust Cookbook locally, run the following command from the root of the Cookbook. ``` -./ci/spellchecker.sh +./ci/spellcheck.sh # or, if you're using a different locale -LANG=en_US.UTF-8 ./ci/spellchecker.sh +LANG=en_US.UTF-8 ./ci/spellcheck.sh ``` If the spell checker finds a misspelled word, you have the opportunity to @@ -100,6 +100,8 @@ correct the spelling mistake with the number keys. If the spelling mistake is erroneous, add the word to the dictionary located in `ci/dictionary.txt`. Pressing `a` or `l` will not add the word to the custom dictionary. +If there are no errors, it will just print the local Aspell version and exit. + [mdbook]: https://github.com/rust-lang-nursery/mdBook [python]: https://packaging.python.org/tutorials/installing-packages/#install-pip-setuptools-and-wheel [skeptic]: https://github.com/brson/rust-skeptic diff --git a/Cargo.toml b/Cargo.toml index 5a89507..c169322 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ nalgebra = "0.16.12" ndarray = "0.12" num = "0.2" num_cpus = "1.8" +percent-encoding = "2.1" petgraph = "0.4" postgres = "0.15" rand = "0.6" @@ -51,7 +52,7 @@ tempdir = "0.3.5" threadpool = "1.6" toml = "0.4" unicode-segmentation = "1.2.1" -url = "1.6" +url = "2.1" walkdir = "2.0" [target.'cfg(target_os = "linux")'.dependencies] diff --git a/src/concurrency/thread/threadpool-fractal.md b/src/concurrency/thread/threadpool-fractal.md index 98e65a8..c94d090 100644 --- a/src/concurrency/thread/threadpool-fractal.md +++ b/src/concurrency/thread/threadpool-fractal.md @@ -42,18 +42,18 @@ use image::{ImageBuffer, Pixel, Rgb}; # let wave = wavelength as f32; # # let (r, g, b) = match wavelength { -# 380...439 => ((440. - wave) / (440. - 380.), 0.0, 1.0), -# 440...489 => (0.0, (wave - 440.) / (490. - 440.), 1.0), -# 490...509 => (0.0, 1.0, (510. - wave) / (510. - 490.)), -# 510...579 => ((wave - 510.) / (580. - 510.), 1.0, 0.0), -# 580...644 => (1.0, (645. - wave) / (645. - 580.), 0.0), -# 645...780 => (1.0, 0.0, 0.0), +# 380..=439 => ((440. - wave) / (440. - 380.), 0.0, 1.0), +# 440..=489 => (0.0, (wave - 440.) / (490. - 440.), 1.0), +# 490..=509 => (0.0, 1.0, (510. - wave) / (510. - 490.)), +# 510..=579 => ((wave - 510.) / (580. - 510.), 1.0, 0.0), +# 580..=644 => (1.0, (645. - wave) / (645. - 580.), 0.0), +# 645..=780 => (1.0, 0.0, 0.0), # _ => (0.0, 0.0, 0.0), # }; # # let factor = match wavelength { -# 380...419 => 0.3 + 0.7 * (wave - 380.) / (420. - 380.), -# 701...780 => 0.3 + 0.7 * (780. - wave) / (780. - 700.), +# 380..=419 => 0.3 + 0.7 * (wave - 380.) / (420. - 380.), +# 701..=780 => 0.3 + 0.7 * (780. - wave) / (780. - 700.), # _ => 1.0, # }; # diff --git a/src/encoding/string/percent-encode.md b/src/encoding/string/percent-encode.md index ec9ffef..7f39058 100644 --- a/src/encoding/string/percent-encode.md +++ b/src/encoding/string/percent-encode.md @@ -1,21 +1,24 @@ ## Percent-encode a string -[![url-badge]][url] [![cat-encoding-badge]][cat-encoding] +[![url-badge]][percent-encoding] [![cat-encoding-badge]][cat-encoding] Encode an input string with [percent-encoding] using the [`utf8_percent_encode`] -function from the `url` crate. Then decode using the [`percent_decode`] +function from the `percent-encoding` crate. Then decode using the [`percent_decode`] function. ```rust -extern crate url; +extern crate percent_encoding; -use url::percent_encoding::{utf8_percent_encode, percent_decode, DEFAULT_ENCODE_SET}; +use percent_encoding::{utf8_percent_encode, percent_decode, AsciiSet, CONTROLS}; use std::str::Utf8Error; +/// https://url.spec.whatwg.org/#fragment-percent-encode-set +const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`'); + fn main() -> Result<(), Utf8Error> { let input = "confident, productive systems programming"; - let iter = utf8_percent_encode(input, DEFAULT_ENCODE_SET); + let iter = utf8_percent_encode(input, FRAGMENT); let encoded: String = iter.collect(); assert_eq!(encoded, "confident,%20productive%20systems%20programming"); From 4e05e2e205d66cc5d300c8ad434bd61b4dc951bc Mon Sep 17 00:00:00 2001 From: Alex Touchet Date: Thu, 19 Sep 2019 11:54:33 -0700 Subject: [PATCH 2/4] Update Travis CI URL (#545) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14756f8..90d2c16 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # A Rust Cookbook   [![Build Status travis]][travis] [![Build Status appveyor]][appveyor] -[Build Status travis]: https://api.travis-ci.org/rust-lang-nursery/rust-cookbook.svg?branch=master -[travis]: https://travis-ci.org/rust-lang-nursery/rust-cookbook +[Build Status travis]: https://api.travis-ci.com/rust-lang-nursery/rust-cookbook.svg?branch=master +[travis]: https://travis-ci.com/rust-lang-nursery/rust-cookbook [Build Status appveyor]: https://ci.appveyor.com/api/projects/status/k56hklb7puv7c4he?svg=true [appveyor]: https://ci.appveyor.com/project/rust-lang-libs/rust-cookbook From 3d908525921594b0a50262bdaf3a83911f6d7f91 Mon Sep 17 00:00:00 2001 From: felipe Date: Fri, 20 Sep 2019 00:25:08 +0530 Subject: [PATCH 3/4] eextern -> extern (#535) was this intentional? --- src/database/sqlite/insert_select.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database/sqlite/insert_select.md b/src/database/sqlite/insert_select.md index df37d86..f6a8c94 100644 --- a/src/database/sqlite/insert_select.md +++ b/src/database/sqlite/insert_select.md @@ -6,7 +6,7 @@ This recipe inserts data into `cat_colors` and `cats` tables using the [`execute`] method of `Connection`. First, the data is inserted into the `cat_colors` table. After a record for a color is inserted, [`last_insert_rowid`] method of `Connection` is used to get `id` of the last color inserted. This `id` is used while inserting data into the `cats` table. Then, the select query is prepared using the [`prepare`] method which gives a [`statement`] struct. Then, query is executed using [`query_map`] method of [`statement`]. ``` -eextern crate rusqlite; +extern crate rusqlite; use rusqlite::{Connection, Result}; use rusqlite::NO_PARAMS; From 6d3f7f97a2fe02d2900933dc28e9a825d16daa91 Mon Sep 17 00:00:00 2001 From: Stefan Hoelzl Date: Thu, 19 Sep 2019 20:56:04 +0200 Subject: [PATCH 4/4] removed unsafe block from rand-choose.md (#536) the unsafe block in this example is not necessary and might confuse beginners. --- src/algorithms/randomness/rand-choose.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/algorithms/randomness/rand-choose.md b/src/algorithms/randomness/rand-choose.md index 8a95c63..acb61fe 100644 --- a/src/algorithms/randomness/rand-choose.md +++ b/src/algorithms/randomness/rand-choose.md @@ -19,8 +19,7 @@ fn main() { let password: String = (0..PASSWORD_LEN) .map(|_| { let idx = rng.gen_range(0, CHARSET.len()); - // This is safe because `idx` is in range of `CHARSET` - char::from(unsafe { *CHARSET.get_unchecked(idx) }) + CHARSET[idx] as char }) .collect();