@@ -45,7 +45,7 @@ For convenience, running `cargo doc --open` will build the HTML for your
4545current crate’s documentation (as well as the documentation for all of your
4646crate’s dependencies) and open the result in a web browser. Navigate to the
4747` add_one ` function and you’ll see how the text in the documentation comments is
48- rendered, as shown in Figure 14-1:
48+ rendered, as shown in Figure 14-1.
4949
5050<img alt =" Rendered HTML documentation for the `add_one` function of `my_crate` " src =" img/trpl14-01.png " class =" center " />
5151
@@ -100,20 +100,20 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
100100```
101101
102102Now, if we change either the function or the example so the ` assert_eq! ` in the
103- example panics and run ` cargo test ` again, we’ll see that the doc tests catch
103+ example panics, and run ` cargo test ` again, we’ll see that the doc tests catch
104104that the example and the code are out of sync with each other!
105105
106106#### Commenting Contained Items
107107
108- The style of doc comment ` //! ` adds documentation to the item that contains the
109- comments rather than to the items following the comments. We typically use
108+ The style of doc comment ` //! ` adds documentation to the item that * contains*
109+ the comments rather than to the items * following* the comments. We typically use
110110these doc comments inside the crate root file (_ src/lib.rs_ by convention) or
111111inside a module to document the crate or the module as a whole.
112112
113113For example, to add documentation that describes the purpose of the ` my_crate `
114114crate that contains the ` add_one ` function, we add documentation comments that
115115start with ` //! ` to the beginning of the _ src/lib.rs_ file, as shown in Listing
116- 14-2:
116+ 14-2.
117117
118118<Listing number =" 14-2 " file-name =" src/lib.rs " caption =" Documentation for the `my_crate` crate as a whole " >
119119
@@ -150,14 +150,14 @@ are and might have difficulty finding the pieces they want to use if your crate
150150has a large module hierarchy.
151151
152152In Chapter 7, we covered how to make items public using the ` pub ` keyword, and
153- bring items into a scope with the ` use ` keyword. However, the structure that
154- makes sense to you while you’re developing a crate might not be very convenient
155- for your users. You might want to organize your structs in a hierarchy
156- containing multiple levels, but then people who want to use a type you’ve
157- defined deep in the hierarchy might have trouble finding out that type exists.
158- They might also be annoyed at having to enter ` use `
159- ` my_crate::some_module::another_module::UsefulType; ` rather than ` use `
160- ` my_crate::UsefulType; ` .
153+ how to bring items into a scope with the ` use ` keyword. However, the structure
154+ that makes sense to you while you’re developing a crate might not be very
155+ convenient for your users. You might want to organize your structs in a
156+ hierarchy containing multiple levels, but then people who want to use a type
157+ you’ve defined deep in the hierarchy might have trouble finding out that type
158+ exists. They might also be annoyed at having to enter `use
159+ my_crate::some_module::another_module::UsefulType;` rather than ` use
160+ my_crate::UsefulType;`.
161161
162162The good news is that if the structure _ isn’t_ convenient for others to use
163163from another library, you don’t have to rearrange your internal organization:
@@ -169,7 +169,7 @@ defined in the other location instead.
169169For example, say we made a library named ` art ` for modeling artistic concepts.
170170Within this library are two modules: a ` kinds ` module containing two enums
171171named ` PrimaryColor ` and ` SecondaryColor ` and a ` utils ` module containing a
172- function named ` mix ` , as shown in Listing 14-3:
172+ function named ` mix ` , as shown in Listing 14-3.
173173
174174<Listing number =" 14-3 " file-name =" src/lib.rs " caption =" An `art` library with items organized into `kinds` and `utils` modules " >
175175
@@ -180,7 +180,7 @@ function named `mix`, as shown in Listing 14-3:
180180</Listing >
181181
182182Figure 14-3 shows what the front page of the documentation for this crate
183- generated by ` cargo doc ` would look like:
183+ generated by ` cargo doc ` would look like.
184184
185185<img alt =" Rendered documentation for the `art` crate that lists the `kinds` and `utils` modules " src =" img/trpl14-03.png " class =" center " />
186186
@@ -194,7 +194,7 @@ see them.
194194Another crate that depends on this library would need ` use ` statements that
195195bring the items from ` art ` into scope, specifying the module structure that’s
196196currently defined. Listing 14-4 shows an example of a crate that uses the
197- ` PrimaryColor ` and ` mix ` items from the ` art ` crate:
197+ ` PrimaryColor ` and ` mix ` items from the ` art ` crate.
198198
199199<Listing number =" 14-4 " file-name =" src/main.rs " caption =" A crate using the `art` crate’s items with its internal structure exported " >
200200
@@ -215,7 +215,7 @@ module names in the `use` statements.
215215
216216To remove the internal organization from the public API, we can modify the
217217` art ` crate code in Listing 14-3 to add ` pub use ` statements to re-export the
218- items at the top level, as shown in Listing 14-5:
218+ items at the top level, as shown in Listing 14-5.
219219
220220<Listing number =" 14-5 " file-name =" src/lib.rs " caption =" Adding `pub use` statements to re-export items " >
221221
@@ -236,7 +236,7 @@ that lists the re-exports</span>
236236
237237The ` art ` crate users can still see and use the internal structure from Listing
23823814-3 as demonstrated in Listing 14-4, or they can use the more convenient
239- structure in Listing 14-5, as shown in Listing 14-6:
239+ structure in Listing 14-5, as shown in Listing 14-6.
240240
241241<Listing number =" 14-6 " file-name =" src/main.rs " caption =" A program using the re-exported items from the `art` crate " >
242242
@@ -370,8 +370,8 @@ license = "MIT OR Apache-2.0"
370370```
371371
372372[ Cargo’s documentation] ( https://doc.rust-lang.org/cargo/ ) describes other
373- metadata you can specify to ensure others can discover and use your crate more
374- easily.
373+ metadata you can specify to ensure that others can discover and use your crate
374+ more easily.
375375
376376### Publishing to Crates.io
377377
@@ -382,11 +382,11 @@ Publishing a crate uploads a specific version to
382382
383383Be careful, because a publish is _ permanent_ . The version can never be
384384overwritten, and the code cannot be deleted except in certain circumstances.
385- One major goal of [ crates .io] ( https://crates.io/ ) <!-- ignore --> is to act as a
386- permanent archive of code so that builds of all projects that depend on crates
387- from [ crates.io] ( https://crates.io/ ) <!-- ignore --> will continue to work.
388- Allowing version deletions would make fulfilling that goal impossible. However,
389- there is no limit to the number of crate versions you can publish.
385+ One major goal of Crates .io is to act as a permanent archive of code so that
386+ builds of all projects that depend on crates from
387+ [ crates.io] ( https://crates.io/ ) <!-- ignore --> will continue to work. Allowing
388+ version deletions would make fulfilling that goal impossible. However, there is
389+ no limit to the number of crate versions you can publish.
390390
391391Run the ` cargo publish ` command again. It should succeed now:
392392
@@ -421,7 +421,7 @@ anyone can easily add your crate as a dependency of their project.
421421When you’ve made changes to your crate and are ready to release a new version,
422422you change the ` version ` value specified in your _ Cargo.toml_ file and
423423republish. Use the [ Semantic Versioning rules] [ semver ] to decide what an
424- appropriate next version number is based on the kinds of changes you’ve made.
424+ appropriate next version number is, based on the kinds of changes you’ve made.
425425Then run ` cargo publish ` to upload the new version.
426426
427427<!-- Old link, do not remove -->
@@ -469,5 +469,5 @@ $ cargo yank --vers 1.0.1 --undo
469469A yank _ does not_ delete any code. It cannot, for example, delete accidentally
470470uploaded secrets. If that happens, you must reset those secrets immediately.
471471
472- [ spdx ] : http ://spdx.org/licenses/
473- [ semver ] : http ://semver.org/
472+ [ spdx ] : https ://spdx.org/licenses/
473+ [ semver ] : https ://semver.org/
0 commit comments