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] 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");