Skip to content

Commit 8df54e6

Browse files
committed
Move errors reorganize datetime add contributing instructions merge master
1 parent 3e03853 commit 8df54e6

24 files changed

+118
-44
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ No worries if anything in these lists is unclear. Just submit the PR and ask awa
1212
- [ ] commits are squashed into one and rebased to latest master
1313
- [ ] PR contains correct "fixes #ISSUE_ID" clause to autoclose the issue on PR merge
1414
- if issue does not exist consider creating it or remove the clause
15+
- [ ] spell check runs without errors `./ci/spellchecker.sh`
16+
- [ ] link check runs without errors `link-checker ./book`
1517
- [ ] non rendered items are in sorted order (links, reference, identifiers, Cargo.toml)
1618
- [ ] links to docs.rs have wildcard version `https://docs.rs/tar/*/tar/struct.Entry.html`
1719
- [ ] example has standard [error handling](https://rust-lang-nursery.github.io/rust-cookbook/about.html#a-note-about-error-handling)

CONTRIBUTING.md

+52
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,61 @@ To run the cookbook test suite:
4444
cargo test
4545
```
4646

47+
## Linters
48+
49+
The Rust Cookbook comes with link checking and spell checking linters that
50+
run on the continuous integration server. These linters should be run locally
51+
before submitting a pull request to ensure there are no dead links or spelling
52+
errors made.
53+
54+
To install the link checker, review the documentation for [python] to install
55+
python 3.6 and pip3. Installing link-checker once the dependencies are met
56+
is done with pip3.
57+
58+
```
59+
[sudo] pip3 install link-checker==0.1.0
60+
```
61+
62+
Alternatively, set up the user install directory on your PATH variable and
63+
install link-checker for your user
64+
65+
```
66+
pip3 install -user link-checker==0.1.0
67+
```
68+
69+
Checking the links of the book locally first requires the book to be built
70+
with mdBook. From the root directory of the cookbook, the following commands
71+
run the link checker.
72+
73+
```
74+
mdbook build
75+
link-checker ./book
76+
```
77+
78+
The aspell binary provides spell checking. Apt packages provide installation
79+
on Debian based operating systems.
80+
81+
```
82+
[sudo] apt install aspell -y
83+
```
84+
85+
To check the spelling of the Rust Cookbook locally, run the following command
86+
from the root of the Cookbook.
87+
88+
```
89+
./ci/spellchecker.sh
90+
```
91+
92+
If the spell checker finds a misspelled word, you have the opportunity to
93+
correct the spelling mistake with the number keys. If the spelling mistake
94+
is erroneous, add the word to the dictionary located in `ci/dictionary.txt`.
95+
Pressing `a` or `l` will not add the word to the custom dictionary.
96+
4797
[mdbook]: http://azerupi.github.io/mdBook/index.html
98+
[python]: https://packaging.python.org/tutorials/installing-packages/#install-pip-setuptools-and-wheel
4899
[skeptic]: https://github.com/brson/rust-skeptic
49100

101+
50102
## Finding what to contribute
51103

52104
This project is intended to be simple to contribute to, and to always

ci/dictionary.txt

+6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ akshat
1212
alisha
1313
AlphaNumeric
1414
ApiResponse
15+
apis
16+
APIs
1517
Appender
1618
appender
19+
applicationx
1720
args
1821
ascii
1922
ashley
@@ -280,6 +283,7 @@ SystemRandom
280283
SystemTime
281284
SystemTimeError
282285
TcpListener
286+
tcpip
283287
TcpStream
284288
TempDir
285289
tempdir
@@ -297,6 +301,7 @@ tuple
297301
Tuple
298302
typesafe
299303
unary
304+
unix
300305
unwinded
301306
UpperHex
302307
uptime
@@ -310,6 +315,7 @@ usize
310315
VarError
311316
versa
312317
Versioning
318+
versioning
313319
VersionReq
314320
vreq
315321
WalkDir

src/SUMMARY.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,35 @@
99
- [Compression](compression.md)
1010
- [Working with Tarballs](compression/tar.md)
1111
- [Concurrency](concurrency.md)
12-
- [Threads](concurrency/threads.md)
13-
- [Parallel Tasks](concurrency/parallel.md)
12+
- [Explicit Threads](concurrency/threads.md)
13+
- [Data Parallelism](concurrency/parallel.md)
1414
- [Cryptography](cryptography.md)
1515
- [Hashing](cryptography/hashing.md)
1616
- [Encryption](cryptography/encryption.md)
1717
- [Data Structures](data_structures.md)
18-
- [Constants](data_structures/constant.md)
19-
- [Custom](data_structures/custom.md)
18+
- [Bitfield](data_structures/bitfield.md)
2019
- [Date and Time](datetime.md)
21-
- [Duration](datetime/duration.md)
20+
- [Duration and Calculation](datetime/duration.md)
2221
- [Parsing and Displaying](datetime/parse.md)
2322
- [Development Tools](development_tools.md)
2423
- [Debugging](development_tools/debugging.md)
2524
- [Log Messages](development_tools/debugging/log.md)
2625
- [Configure Logging](development_tools/debugging/config_log.md)
2726
- [Versioning](development_tools/versioning.md)
28-
- [Error Handling](development_tools/errors.md)
2927
- [Build Time Tooling](development_tools/build_tools.md)
3028
- [Encoding](encoding.md)
3129
- [Strings](encoding/strings.md)
3230
- [CSV processing](encoding/csv.md)
3331
- [Complex Data Types](encoding/complex.md)
32+
- [Error Handling](errors.md)
33+
- [Handle Error Variants](errors/handle.md)
3434
- [File System](file.md)
3535
- [Read & Write](file/read-write.md)
3636
- [Directory Traversal](file/dir.md)
3737
- [Hardware Support](hardware.md)
3838
- [Processor](hardware/processor.md)
39+
- [Memory Management](mem.md)
40+
- [Global Static](mem/global_static.md)
3941
- [Network](net.md)
4042
- [Server](net/server.md)
4143
- [Operating System](os.md)

src/data_structures.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
| Recipe | Crates | Categories |
44
|--------|--------|------------|
5-
| [Declare lazily evaluated constant][ex-lazy-constant] | [![lazy_static-badge]][lazy_static] | [![cat-caching-badge]][cat-caching] [![cat-rust-patterns-badge]][cat-rust-patterns] |
65
| [Define and operate on a type represented as a bitfield][ex-bitflags] | [![bitflags-badge]][bitflags] | [![cat-no-std-badge]][cat-no-std] |
76

8-
[ex-lazy-constant]: data_structures/constant.html#declare-lazily-evaluated-constant
9-
10-
[ex-bitflags]: data_structures/custom.html#define-and-operate-on-a-type-represented-as-a-bitfield
7+
[ex-bitflags]: data_structures/bitfield.html#define-and-operate-on-a-type-represented-as-a-bitfield
118

129
{{#include links.md}}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Custom
22

3-
{{#include custom/bitfield.md}}
3+
{{#include bitfield/bitfield.md}}
44

55
{{#include ../links.md}}

src/data_structures/constant.md

-5
This file was deleted.

src/datetime.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
|--------|--------|------------|
55
| [Measure elapsed time][ex-measure-elapsed-time] | [![std-badge]][std] | [![cat-time-badge]][cat-time] |
66
| [Perform checked date and time calculations][ex-datetime-arithmetic] | [![chrono-badge]][chrono] | [![cat-date-and-time-badge]][cat-date-and-time] |
7+
| [Convert a local time to another timezone][ex-convert-datetime-timezone] | [![chrono-badge]][chrono] | [![cat-date-and-time-badge]][cat-date-and-time] |
78
| [Examine the date and time][ex-examine-date-and-time] | [![chrono-badge]][chrono] | [![cat-date-and-time-badge]][cat-date-and-time] |
89
| [Convert date to UNIX timestamp and vice versa][ex-convert-datetime-timestamp] | [![chrono-badge]][chrono] | [![cat-date-and-time-badge]][cat-date-and-time] |
9-
| [Convert a local time to an another UTC timezone and vice versa][ex-convert-datetime-timezone] | [![chrono-badge]][chrono] | [![cat-date-and-time-badge]][cat-date-and-time] |
1010
| [Display formatted date and time][ex-format-datetime] | [![chrono-badge]][chrono] | [![cat-date-and-time-badge]][cat-date-and-time] |
1111
| [Parse string into DateTime struct][ex-parse-datetime] | [![chrono-badge]][chrono] | [![cat-date-and-time-badge]][cat-date-and-time] |
1212

1313
[ex-measure-elapsed-time]: datetime/duration.html#measure-the-elapsed-time-between-two-code-sections
1414
[ex-datetime-arithmetic]: datetime/duration.html#perform-checked-date-and-time-calculations
15-
[ex-examine-date-and-time]: datetime/duration.html#examine-the-date-and-time
16-
[ex-convert-datetime-timestamp]: datetime/parse.html#convert-date-to-unix-timestamp-and-vice-versa
15+
[ex-convert-datetime-timestamp]: datetime/duration.html#convert-a-local-time-to-another-timezone
16+
[ex-examine-date-and-time]: datetime/parse.html#examine-the-date-and-time
1717
[ex-convert-datetime-timezone]: datetime/parse.html#convert-a-local-time-to-an-another-utc-timezone-and-vice-versa
1818
[ex-format-datetime]: datetime/parse.html#display-formatted-date-and-time
1919
[ex-parse-datetime]: datetime/parse.html#parse-string-into-datetime-struct

src/datetime/duration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Duration
1+
# Duration and Calculation
22

33
{{#include duration/profile.md}}
44

55
{{#include duration/checked.md}}
66

7-
{{#include duration/current.md}}
7+
{{#include duration/timezone.md}}
88

99
{{#include ../links.md}}

src/datetime/parse/timezone.md renamed to src/datetime/duration/timezone.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Convert a local time to an another UTC timezone and vice versa
1+
## Convert a local time to another timezone
22

33
[![chrono-badge]][chrono] [![cat-date-and-time-badge]][cat-date-and-time]
44

src/datetime/parse.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Parsing and Displaying
22

3-
{{#include parse/timestamp.md}}
3+
{{#include parse/current.md}}
44

5-
{{#include parse/timezone.md}}
5+
{{#include parse/timestamp.md}}
66

77
{{#include parse/format.md}}
88

File renamed without changes.

src/development_tools.md

-12
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@
1212
| [Find the latest version satisfying given range][ex-semver-latest] | [![semver-badge]][semver] | [![cat-config-badge]][cat-config] |
1313
| [Check external command version for compatibility][ex-semver-command] | [![semver-badge]][semver] | [![cat-text-processing-badge]][cat-text-processing] [![cat-os-badge]][cat-os]
1414

15-
## Error Handling
16-
17-
| Recipe | Crates | Categories |
18-
|--------|--------|------------|
19-
| [Handle errors correctly in main][ex-error-chain-simple-error-handling] | [![error-chain-badge]][error-chain] | [![cat-rust-patterns-badge]][cat-rust-patterns] |
20-
| [Avoid discarding errors during error conversions][ex-error-chain-avoid-discarding] | [![error-chain-badge]][error-chain] | [![cat-rust-patterns-badge]][cat-rust-patterns] |
21-
| [Obtain backtrace of complex error scenarios][ex-error-chain-backtrace] | [![error-chain-badge]][error-chain] | [![cat-rust-patterns-badge]][cat-rust-patterns] |
22-
2315
## Build Time
2416

2517
| Recipe | Crates | Categories |
@@ -34,10 +26,6 @@
3426
[ex-semver-latest]: development_tools/versioning.html#find-the-latest-version-satisfying-given-range
3527
[ex-semver-command]: development_tools/versioning.html#check-external-command-version-for-compatibility
3628

37-
[ex-error-chain-simple-error-handling]: development_tools/errors.html#handle-errors-correctly-in-main
38-
[ex-error-chain-avoid-discarding]: development_tools/errors.html#avoid-discarding-errors-during-error-conversions
39-
[ex-error-chain-backtrace]: development_tools/errors.html#obtain-backtrace-of-complex-error-scenarios
40-
4129
[ex-cc-static-bundled]: development_tools/build_tools.html#compile-and-link-statically-to-a-bundled-c-library
4230
[ex-cc-static-bundled-cpp]: development_tools/build_tools.html#compile-and-link-statically-to-a-bundled-c-library-1
4331
[ex-cc-custom-defines]: development_tools/build_tools.html#compile-a-c-library-while-setting-custom-defines

src/development_tools/errors.md

-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1 @@
11
# Error Handling
2-
3-
{{#include errors/main.md}}
4-
5-
{{#include errors/retain.md}}
6-
7-
{{#include errors/backtrace.md}}
8-
9-
{{#include ../links.md}}

src/errors.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Error Handling
2+
3+
| Recipe | Crates | Categories |
4+
|--------|--------|------------|
5+
| [Handle errors correctly in main][ex-error-chain-simple-error-handling] | [![error-chain-badge]][error-chain] | [![cat-rust-patterns-badge]][cat-rust-patterns] |
6+
| [Avoid discarding errors during error conversions][ex-error-chain-avoid-discarding] | [![error-chain-badge]][error-chain] | [![cat-rust-patterns-badge]][cat-rust-patterns] |
7+
| [Obtain backtrace of complex error scenarios][ex-error-chain-backtrace] | [![error-chain-badge]][error-chain] | [![cat-rust-patterns-badge]][cat-rust-patterns] |
8+
9+
[ex-error-chain-simple-error-handling]: errors/handle.html#handle-errors-correctly-in-main
10+
[ex-error-chain-avoid-discarding]: errors/handle.html#avoid-discarding-errors-during-error-conversions
11+
[ex-error-chain-backtrace]: errors/handle.html#obtain-backtrace-of-complex-error-scenarios
12+
13+
{{#include links.md}}

src/errors/handle.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Error Handling
2+
3+
{{#include handle/main.md}}
4+
5+
{{#include handle/retain.md}}
6+
7+
{{#include handle/backtrace.md}}
8+
9+
{{#include ../links.md}}
File renamed without changes.
File renamed without changes.

src/intro.md

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ community. It needs and welcomes help. For details see
2828

2929
{{#include data_structures.md}}
3030

31+
{{#include datetime.md}}
32+
3133
{{#include development_tools.md}}
3234

3335
{{#include encoding.md}}
@@ -36,6 +38,8 @@ community. It needs and welcomes help. For details see
3638

3739
{{#include hardware.md}}
3840

41+
{{#include mem.md}}
42+
3943
{{#include net.md}}
4044

4145
{{#include os.md}}

src/mem.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Memory Management
2+
3+
| Recipe | Crates | Categories |
4+
|--------|--------|------------|
5+
| [Declare lazily evaluated constant][ex-lazy-constant] | [![lazy_static-badge]][lazy_static] | [![cat-caching-badge]][cat-caching] [![cat-rust-patterns-badge]][cat-rust-patterns] |
6+
7+
[ex-lazy-constant]: mem/global_static.html#declare-lazily-evaluated-constant
8+
9+
{{#include links.md}}

src/mem/global_static.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Constants
2+
3+
{{#include global_static/lazy-constant.md}}
4+
5+
{{#include ../links.md}}

0 commit comments

Comments
 (0)