mirror of https://github.com/rust-lang/book
Merge `main` into `chriskrycho/vhb`
This commit is contained in:
commit
523d960984
|
@ -3,8 +3,12 @@ name: Bug report
|
|||
about: Create a report to help us improve
|
||||
---
|
||||
|
||||
- [ ] I have checked the latest `main` branch to see if this has already been fixed
|
||||
- [ ] I have searched existing issues and pull requests for duplicates
|
||||
- I have searched open and closed issues and pull requests for duplicates, using these search terms:
|
||||
-
|
||||
-
|
||||
-
|
||||
- I have checked the latest `main` branch to see if this has already been fixed, in this file:
|
||||
-
|
||||
|
||||
URL to the section(s) of the book with this problem:
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ jobs:
|
|||
- name: Install Rust
|
||||
run: |
|
||||
rustup set profile minimal
|
||||
rustup toolchain install 1.62 -c rust-docs
|
||||
rustup default 1.62
|
||||
rustup toolchain install 1.76 -c rust-docs
|
||||
rustup default 1.76
|
||||
- name: Install mdbook
|
||||
run: |
|
||||
mkdir bin
|
||||
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
|
||||
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.21/mdbook-v0.4.21-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
|
||||
echo "$(pwd)/bin" >> ${GITHUB_PATH}
|
||||
- name: Report versions
|
||||
run: |
|
||||
|
@ -41,7 +41,7 @@ jobs:
|
|||
- name: Install mdbook
|
||||
run: |
|
||||
mkdir bin
|
||||
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
|
||||
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.21/mdbook-v0.4.21-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
|
||||
echo "$(pwd)/bin" >> ${GITHUB_PATH}
|
||||
- name: Install aspell
|
||||
run: sudo apt-get install aspell
|
||||
|
|
|
@ -113,7 +113,12 @@ To check, say, updating `mdbook` or changing the way files get included:
|
|||
|
||||
## Produce markdown from docx for diffing
|
||||
|
||||
- TODO Carol to document this next time she does it
|
||||
- Save the docx file to `tmp/chapterXX.docx`.
|
||||
- In Word, go to the review tab, choose "Accept all changes and stop tracking"
|
||||
- Save the docx again and close Word
|
||||
- Run `./tools/doc-to-md.sh`
|
||||
- This should write `nostarch/chapterXX.md`. Adjust the XSL in
|
||||
`tools/doc-to-md.xsl` and run `./tools/doc-to-md.sh` again if needed.
|
||||
|
||||
## Generate Graphviz dot
|
||||
|
||||
|
|
|
@ -38,11 +38,13 @@ that governs all sub-projects, including this one. Please respect it!
|
|||
|
||||
## Expectations
|
||||
|
||||
Because the book is [printed](https://nostarch.com/rust), and because we want
|
||||
Because the book is [printed][nostarch], and because we want
|
||||
to keep the online version of the book close to the print version when
|
||||
possible, it may take longer than you're used to for us to address your issue
|
||||
or pull request.
|
||||
|
||||
[nostarch]: https://nostarch.com/rust-programming-language-2nd-edition
|
||||
|
||||
So far, we've been doing a larger revision to coincide with [Rust
|
||||
Editions](https://doc.rust-lang.org/edition-guide/). Between those larger
|
||||
revisions, we will only be correcting errors. If your issue or pull request
|
||||
|
@ -68,4 +70,4 @@ a new language! We're waiting on [mdbook support] for multiple languages
|
|||
before we merge any in, but feel free to start!
|
||||
|
||||
[Translations]: https://github.com/rust-lang/book/issues?q=is%3Aopen+is%3Aissue+label%3ATranslations
|
||||
[mdbook support]: https://github.com/rust-lang-nursery/mdBook/issues/5
|
||||
[mdbook support]: https://github.com/rust-lang/mdBook/issues/5
|
||||
|
|
293
COPYRIGHT
293
COPYRIGHT
|
@ -1,290 +1,3 @@
|
|||
Short version for non-lawyers:
|
||||
|
||||
The Rust Project is dual-licensed under Apache 2.0 and MIT
|
||||
terms.
|
||||
|
||||
|
||||
Longer version:
|
||||
|
||||
The Rust Project is copyright 2010, The Rust Project
|
||||
Developers.
|
||||
|
||||
Licensed under the Apache License, Version 2.0
|
||||
<LICENSE-APACHE or
|
||||
https://www.apache.org/licenses/LICENSE-2.0> or the MIT
|
||||
license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
|
||||
at your option. All files in the project carrying such
|
||||
notice may not be copied, modified, or distributed except
|
||||
according to those terms.
|
||||
|
||||
|
||||
The Rust Project includes packages written by third parties.
|
||||
The following third party packages are included, and carry
|
||||
their own copyright notices and license terms:
|
||||
|
||||
* The src/rt/miniz.c file, carrying an implementation of
|
||||
RFC1950/RFC1951 DEFLATE, by Rich Geldreich
|
||||
<richgel99@gmail.com>. All uses of this file are
|
||||
permitted by the embedded "unlicense" notice
|
||||
(effectively: public domain with warranty disclaimer).
|
||||
|
||||
* LLVM. Code for this package is found in src/llvm.
|
||||
|
||||
Copyright (c) 2003-2013 University of Illinois at
|
||||
Urbana-Champaign. All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
https://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal with the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
* Redistributions of source code must retain the
|
||||
above copyright notice, this list of conditions
|
||||
and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the
|
||||
above copyright notice, this list of conditions
|
||||
and the following disclaimers in the documentation
|
||||
and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of
|
||||
Illinois at Urbana-Champaign, nor the names of its
|
||||
contributors may be used to endorse or promote
|
||||
products derived from this Software without
|
||||
specific prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS WITH THE SOFTWARE.
|
||||
|
||||
* Additional libraries included in LLVM carry separate
|
||||
BSD-compatible licenses. See src/llvm/LICENSE.txt for
|
||||
details.
|
||||
|
||||
* compiler-rt, in src/compiler-rt is dual licensed under
|
||||
LLVM's license and MIT:
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in
|
||||
CREDITS.TXT
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Developed by:
|
||||
|
||||
LLVM Team
|
||||
|
||||
University of Illinois at Urbana-Champaign
|
||||
|
||||
https://llvm.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal with the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
* Redistributions of source code must retain the
|
||||
above copyright notice, this list of conditions
|
||||
and the following disclaimers.
|
||||
|
||||
* Redistributions in binary form must reproduce the
|
||||
above copyright notice, this list of conditions
|
||||
and the following disclaimers in the documentation
|
||||
and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the names of the LLVM Team, University of
|
||||
Illinois at Urbana-Champaign, nor the names of its
|
||||
contributors may be used to endorse or promote
|
||||
products derived from this Software without
|
||||
specific prior written permission.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS WITH THE SOFTWARE.
|
||||
|
||||
========================================================
|
||||
|
||||
Copyright (c) 2009-2014 by the contributors listed in
|
||||
CREDITS.TXT
|
||||
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
* Portions of the FFI code for interacting with the native ABI
|
||||
is derived from the Clay programming language, which carries
|
||||
the following license.
|
||||
|
||||
Copyright (C) 2008-2010 Tachyon Technologies.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with
|
||||
or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the
|
||||
above copyright notice, this list of conditions and
|
||||
the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
|
||||
* libbacktrace, under src/libbacktrace:
|
||||
|
||||
Copyright (C) 2012-2014 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with
|
||||
or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
|
||||
(1) Redistributions of source code must retain the
|
||||
above copyright notice, this list of conditions and
|
||||
the following disclaimer.
|
||||
|
||||
(2) Redistributions in binary form must reproduce
|
||||
the above copyright notice, this list of conditions
|
||||
and the following disclaimer in the documentation
|
||||
and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
(3) The name of the author may not be used to
|
||||
endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE. */
|
||||
|
||||
* jemalloc, under src/jemalloc:
|
||||
|
||||
Copyright (C) 2002-2014 Jason Evans
|
||||
<jasone@canonware.com>. All rights reserved.
|
||||
Copyright (C) 2007-2012 Mozilla Foundation.
|
||||
All rights reserved.
|
||||
Copyright (C) 2009-2014 Facebook, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright notice(s),
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice(s),
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S)
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S)
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
|
||||
* Additional copyright may be retained by contributors other
|
||||
than Mozilla, the Rust Project Developers, or the parties
|
||||
enumerated in this file. Such copyright can be determined
|
||||
on a case-by-case basis by examining the author of each
|
||||
portion of a file in the revision-control commit records
|
||||
of the project, or by consulting representative comments
|
||||
claiming copyright ownership for a file.
|
||||
|
||||
For example, the text:
|
||||
|
||||
"Copyright (c) 2011 Google Inc."
|
||||
|
||||
appears in some files, and these files thereby denote
|
||||
that their author and copyright-holder is Google Inc.
|
||||
|
||||
In all such cases, the absence of explicit licensing text
|
||||
indicates that the contributor chose to license their work
|
||||
for distribution under identical terms to those Mozilla
|
||||
has chosen for the collective work, enumerated at the top
|
||||
of this file. The only difference is the retention of
|
||||
copyright itself, held by the contributor.
|
||||
This repository is licensed under the Apache License, Version 2.0
|
||||
<LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT
|
||||
license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
|
||||
|
|
|
@ -101,18 +101,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.39"
|
||||
version = "1.0.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
|
||||
checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.18"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
@ -167,18 +167,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.137"
|
||||
version = "1.0.197"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
|
||||
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.137"
|
||||
version = "1.0.197"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
|
||||
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -193,9 +193,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.96"
|
||||
version = "2.0.59"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
|
||||
checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
name = "rust-book"
|
||||
version = "0.0.1"
|
||||
description = "The Rust Book"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "concat_chapters"
|
||||
|
|
|
@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
|
|||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
Copyright 2010 The Rust Project Developers
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
12
README.md
12
README.md
|
@ -6,7 +6,7 @@ This repository contains the source of "The Rust Programming Language" book.
|
|||
|
||||
[The book is available in dead-tree form from No Starch Press][nostarch].
|
||||
|
||||
[nostarch]: https://nostarch.com/rust
|
||||
[nostarch]: https://nostarch.com/rust-programming-language-2nd-edition
|
||||
|
||||
You can also read the book for free online. Please see the book as shipped with
|
||||
the latest [stable], [beta], or [nightly] Rust releases. Be aware that issues
|
||||
|
@ -26,11 +26,11 @@ See the [releases] to download just the code of all the code listings that appea
|
|||
Building the book requires [mdBook], ideally the same version that
|
||||
rust-lang/rust uses in [this file][rust-mdbook]. To get it:
|
||||
|
||||
[mdBook]: https://github.com/rust-lang-nursery/mdBook
|
||||
[mdBook]: https://github.com/rust-lang/mdBook
|
||||
[rust-mdbook]: https://github.com/rust-lang/rust/blob/master/src/tools/rustbook/Cargo.toml
|
||||
|
||||
```bash
|
||||
$ cargo install mdbook --vers [version-num]
|
||||
$ cargo install mdbook --locked --version <version_num>
|
||||
```
|
||||
|
||||
## Building
|
||||
|
@ -73,7 +73,7 @@ kinds of contributions we're looking for.
|
|||
|
||||
[contrib]: https://github.com/rust-lang/book/blob/main/CONTRIBUTING.md
|
||||
|
||||
Because the book is [printed](https://nostarch.com/rust), and because we want
|
||||
Because the book is [printed][nostarch], and because we want
|
||||
to keep the online version of the book close to the print version when
|
||||
possible, it may take longer than you're used to for us to address your issue
|
||||
or pull request.
|
||||
|
@ -93,13 +93,13 @@ a new language! We're waiting on [mdbook support] for multiple languages
|
|||
before we merge any in, but feel free to start!
|
||||
|
||||
[Translations]: https://github.com/rust-lang/book/issues?q=is%3Aopen+is%3Aissue+label%3ATranslations
|
||||
[mdbook support]: https://github.com/rust-lang-nursery/mdBook/issues/5
|
||||
[mdbook support]: https://github.com/rust-lang/mdBook/issues/5
|
||||
|
||||
## Spellchecking
|
||||
|
||||
To scan source files for spelling errors, you can use the `spellcheck.sh`
|
||||
script available in the `ci` directory. It needs a dictionary of valid words,
|
||||
which is provided in `ci/dictionary.txt`. If the script produces a false
|
||||
positive (say, you used word `BTreeMap` which the script considers invalid),
|
||||
positive (say, you used the word `BTreeMap` which the script considers invalid),
|
||||
you need to add this word to `ci/dictionary.txt` (keep the sorted order for
|
||||
consistency).
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# In each chapter
|
||||
|
||||
- [ ] Manual regeneration
|
||||
- [ ] Check for upstream changes from last snapshot
|
||||
- [ ] Propagate updated output to docx
|
||||
- [ ] Extract docx and check diff
|
||||
- [ ] Answer all comments
|
||||
- [ ] Check cross references
|
||||
- [ ] Check indentation of --snip--
|
||||
- [ ] Numbered lines, Gray out unchanged lines
|
||||
- [ ] Check line wrapping
|
||||
- [ ] Check for unneeded command/compiling/running output
|
||||
- [ ] Check println style and error messages
|
||||
- [ ] Add alt text to images
|
||||
- [ ] Index tags
|
||||
- [ ] search for "convention" conventions:naming:of blah
|
||||
- [ ] check for double spaces, spaces at the end of paragraphs
|
|
@ -35,6 +35,7 @@ backtraces
|
|||
BACKTRACE
|
||||
Backtraces
|
||||
Baz's
|
||||
beefeb
|
||||
benchmarking
|
||||
bioinformatics
|
||||
bitand
|
||||
|
@ -537,6 +538,7 @@ uncommenting
|
|||
unevaluated
|
||||
Uninstalling
|
||||
uninstall
|
||||
unittests
|
||||
unix
|
||||
unpopulated
|
||||
unoptimized
|
||||
|
@ -545,6 +547,7 @@ unsafety
|
|||
unsized
|
||||
unsynchronized
|
||||
Unyank
|
||||
UpperCamelCase
|
||||
URIs
|
||||
UsefulType
|
||||
username
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -8,9 +10,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
|
@ -26,33 +28,32 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.86"
|
||||
version = "0.2.153"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
|
||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.10"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
|
@ -60,24 +61,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.2"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -5,16 +5,20 @@ $ cargo build
|
|||
Compiling ppv-lite86 v0.2.10
|
||||
Compiling rand_core v0.6.2
|
||||
Compiling rand_chacha v0.3.0
|
||||
Compiling rand v0.8.3
|
||||
Compiling rand v0.8.5
|
||||
Compiling guessing_game v0.1.0 (file:///projects/guessing_game)
|
||||
error[E0308]: mismatched types
|
||||
--> src/main.rs:22:21
|
||||
|
|
||||
22 | match guess.cmp(&secret_number) {
|
||||
| ^^^^^^^^^^^^^^ expected struct `String`, found integer
|
||||
| --- ^^^^^^^^^^^^^^ expected `&String`, found `&{integer}`
|
||||
| |
|
||||
| arguments to this method are incorrect
|
||||
|
|
||||
= note: expected reference `&String`
|
||||
found reference `&{integer}`
|
||||
note: method defined here
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/cmp.rs:814:8
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `guessing_game` due to previous error
|
||||
error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -4,10 +4,14 @@ warning: unused `Result` that must be used
|
|||
--> src/main.rs:10:5
|
||||
|
|
||||
10 | io::stdin().read_line(&mut guess);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_must_use)]` on by default
|
||||
= note: this `Result` may be an `Err` variant, which should be handled
|
||||
= note: `#[warn(unused_must_use)]` on by default
|
||||
help: use `let _ = ...` to ignore the resulting value
|
||||
|
|
||||
10 | let _ = io::stdin().read_line(&mut guess);
|
||||
| +++++++
|
||||
|
||||
warning: `guessing_game` (bin "guessing_game") generated 1 warning
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.59s
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -13,4 +13,4 @@ error[E0384]: cannot assign twice to immutable variable `x`
|
|||
| ^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
For more information about this error, try `rustc --explain E0384`.
|
||||
error: could not compile `variables` due to previous error
|
||||
error: could not compile `variables` (bin "variables") due to 1 previous error
|
||||
|
|
|
@ -7,6 +7,12 @@ error[E0308]: mismatched types
|
|||
| ----- expected due to this value
|
||||
3 | spaces = spaces.len();
|
||||
| ^^^^^^^^^^^^ expected `&str`, found `usize`
|
||||
|
|
||||
help: try removing the method call
|
||||
|
|
||||
3 - spaces = spaces.len();
|
||||
3 + spaces = spaces;
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `variables` due to previous error
|
||||
error: could not compile `variables` (bin "variables") due to 1 previous error
|
||||
|
|
|
@ -10,7 +10,7 @@ fn main() {
|
|||
|
||||
// division
|
||||
let quotient = 56.7 / 32.2;
|
||||
let floored = 2 / 3; // Results in 0
|
||||
let truncated = -5 / 3; // Results in -1
|
||||
|
||||
// remainder
|
||||
let remainder = 43 % 5;
|
||||
|
|
|
@ -1,20 +1,12 @@
|
|||
$ cargo run
|
||||
Compiling functions v0.1.0 (file:///projects/functions)
|
||||
error: expected expression, found statement (`let`)
|
||||
error: expected expression, found `let` statement
|
||||
--> src/main.rs:2:14
|
||||
|
|
||||
2 | let x = (let y = 6);
|
||||
| ^^^^^^^^^
|
||||
| ^^^
|
||||
|
|
||||
= note: variable declaration using `let` is a statement
|
||||
|
||||
error[E0658]: `let` expressions in this position are unstable
|
||||
--> src/main.rs:2:14
|
||||
|
|
||||
2 | let x = (let y = 6);
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
|
||||
warning: unnecessary parentheses around assigned value
|
||||
--> src/main.rs:2:13
|
||||
|
@ -27,8 +19,7 @@ help: remove these parentheses
|
|||
|
|
||||
2 - let x = (let y = 6);
|
||||
2 + let x = let y = 6;
|
||||
|
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
warning: `functions` (bin "functions") generated 1 warning
|
||||
error: could not compile `functions` due to 2 previous errors; 1 warning emitted
|
||||
error: could not compile `functions` (bin "functions") due to 1 previous error; 1 warning emitted
|
||||
|
|
|
@ -8,7 +8,7 @@ error[E0308]: mismatched types
|
|||
| |
|
||||
| implicitly returns `()` as its body has no tail or `return` expression
|
||||
8 | x + 1;
|
||||
| - help: remove this semicolon
|
||||
| - help: remove this semicolon to return this value
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `functions` due to previous error
|
||||
error: could not compile `functions` (bin "functions") due to 1 previous error
|
||||
|
|
|
@ -7,4 +7,4 @@ error[E0308]: mismatched types
|
|||
| ^^^^^^ expected `bool`, found integer
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `branches` due to previous error
|
||||
error: could not compile `branches` (bin "branches") due to 1 previous error
|
||||
|
|
|
@ -9,4 +9,4 @@ error[E0308]: `if` and `else` have incompatible types
|
|||
| expected because of this
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: could not compile `branches` due to previous error
|
||||
error: could not compile `branches` (bin "branches") due to 1 previous error
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
$ cargo build
|
||||
Compiling no_type_annotations v0.1.0 (file:///projects/no_type_annotations)
|
||||
error[E0282]: type annotations needed
|
||||
error[E0284]: type annotations needed
|
||||
--> src/main.rs:2:9
|
||||
|
|
||||
2 | let guess = "42".parse().expect("Not a number!");
|
||||
| ^^^^^ consider giving `guess` a type
|
||||
| ^^^^^ ----- type must be known at this point
|
||||
|
|
||||
= note: cannot satisfy `<_ as FromStr>::Err == _`
|
||||
help: consider giving `guess` an explicit type
|
||||
|
|
||||
2 | let guess: /* Type */ = "42".parse().expect("Not a number!");
|
||||
| ++++++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
||||
error: could not compile `no_type_annotations` due to previous error
|
||||
For more information about this error, try `rustc --explain E0284`.
|
||||
error: could not compile `no_type_annotations` (bin "no_type_annotations") due to 1 previous error
|
||||
|
|
|
@ -6,4 +6,4 @@ fn main() {
|
|||
// do stuff with s
|
||||
} // this scope is now over, and s is no longer valid
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,10 @@ fn main() {
|
|||
// special happens.
|
||||
|
||||
fn takes_ownership(some_string: String) { // some_string comes into scope
|
||||
println!("{}", some_string);
|
||||
println!("{some_string}");
|
||||
} // Here, some_string goes out of scope and `drop` is called. The backing
|
||||
// memory is freed.
|
||||
|
||||
fn makes_copy(some_integer: i32) { // some_integer comes into scope
|
||||
println!("{}", some_integer);
|
||||
println!("{some_integer}");
|
||||
} // Here, some_integer goes out of scope. Nothing special happens.
|
||||
|
|
|
@ -3,7 +3,7 @@ fn main() {
|
|||
|
||||
let (s2, len) = calculate_length(s1);
|
||||
|
||||
println!("The length of '{}' is {}.", s2, len);
|
||||
println!("The length of '{s2}' is {len}.");
|
||||
}
|
||||
|
||||
fn calculate_length(s: String) -> (String, usize) {
|
||||
|
|
|
@ -3,10 +3,13 @@ $ cargo run
|
|||
error[E0596]: cannot borrow `*some_string` as mutable, as it is behind a `&` reference
|
||||
--> src/main.rs:8:5
|
||||
|
|
||||
7 | fn change(some_string: &String) {
|
||||
| ------- help: consider changing this to be a mutable reference: `&mut String`
|
||||
8 | some_string.push_str(", world");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
| ^^^^^^^^^^^ `some_string` is a `&` reference, so the data it refers to cannot be borrowed as mutable
|
||||
|
|
||||
help: consider changing this to be a mutable reference
|
||||
|
|
||||
7 | fn change(some_string: &mut String) {
|
||||
| +++
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -4,6 +4,6 @@ fn main() {
|
|||
|
||||
s.push_str(", world!"); // push_str() appends a literal to a String
|
||||
|
||||
println!("{}", s); // This will print `hello, world!`
|
||||
// ANCHOR_END: here
|
||||
println!("{s}"); // This will print `hello, world!`
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -7,11 +7,15 @@ error[E0382]: borrow of moved value: `s1`
|
|||
| -- move occurs because `s1` has type `String`, which does not implement the `Copy` trait
|
||||
3 | let s2 = s1;
|
||||
| -- value moved here
|
||||
4 |
|
||||
4 |
|
||||
5 | println!("{}, world!", s1);
|
||||
| ^^ value borrowed here after move
|
||||
|
|
||||
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider cloning the value if the performance cost is acceptable
|
||||
|
|
||||
3 | let s2 = s1.clone();
|
||||
| ++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -3,6 +3,6 @@ fn main() {
|
|||
let s1 = String::from("hello");
|
||||
let s2 = s1;
|
||||
|
||||
println!("{}, world!", s1);
|
||||
println!("{s1}, world!");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@ fn main() {
|
|||
let s1 = String::from("hello");
|
||||
let s2 = s1.clone();
|
||||
|
||||
println!("s1 = {}, s2 = {}", s1, s2);
|
||||
println!("s1 = {s1}, s2 = {s2}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -3,6 +3,6 @@ fn main() {
|
|||
let x = 5;
|
||||
let y = x;
|
||||
|
||||
println!("x = {}, y = {}", x, y);
|
||||
println!("x = {x}, y = {y}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
|||
let len = calculate_length(&s1);
|
||||
// ANCHOR_END: here
|
||||
|
||||
println!("The length of '{}' is {}.", s1, len);
|
||||
println!("The length of '{s1}' is {len}.");
|
||||
}
|
||||
|
||||
fn calculate_length(s: &String) -> usize {
|
||||
|
|
|
@ -3,7 +3,7 @@ fn main() {
|
|||
|
||||
let len = calculate_length(&s1);
|
||||
|
||||
println!("The length of '{}' is {}.", s1, len);
|
||||
println!("The length of '{s1}' is {len}.");
|
||||
}
|
||||
|
||||
// ANCHOR: here
|
||||
|
|
|
@ -7,9 +7,9 @@ error[E0499]: cannot borrow `s` as mutable more than once at a time
|
|||
| ------ first mutable borrow occurs here
|
||||
5 | let r2 = &mut s;
|
||||
| ^^^^^^ second mutable borrow occurs here
|
||||
6 |
|
||||
6 |
|
||||
7 | println!("{}, {}", r1, r2);
|
||||
| -- first borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -8,9 +8,9 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta
|
|||
5 | let r2 = &s; // no problem
|
||||
6 | let r3 = &mut s; // BIG PROBLEM
|
||||
| ^^^^^^ mutable borrow occurs here
|
||||
7 |
|
||||
7 |
|
||||
8 | println!("{}, {}, and {}", r1, r2, r3);
|
||||
| -- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -4,10 +4,10 @@ fn main() {
|
|||
|
||||
let r1 = &s; // no problem
|
||||
let r2 = &s; // no problem
|
||||
println!("{} and {}", r1, r2);
|
||||
println!("{r1} and {r2}");
|
||||
// variables r1 and r2 will not be used after this point
|
||||
|
||||
let r3 = &mut s; // no problem
|
||||
println!("{}", r3);
|
||||
println!("{r3}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -7,10 +7,15 @@ error[E0106]: missing lifetime specifier
|
|||
| ^ expected named lifetime parameter
|
||||
|
|
||||
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||
help: consider using the `'static` lifetime
|
||||
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
||||
|
|
||||
5 | fn dangle() -> &'static String {
|
||||
| ~~~~~~~~
|
||||
| +++++++
|
||||
help: instead, you are more likely to want to return an owned value
|
||||
|
|
||||
5 - fn dangle() -> &String {
|
||||
5 + fn dangle() -> String {
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -5,12 +5,12 @@ error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immuta
|
|||
|
|
||||
16 | let word = first_word(&s);
|
||||
| -- immutable borrow occurs here
|
||||
17 |
|
||||
17 |
|
||||
18 | s.clear(); // error!
|
||||
| ^^^^^^^^^ mutable borrow occurs here
|
||||
19 |
|
||||
19 |
|
||||
20 | println!("the first word is: {}", word);
|
||||
| ---- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `ownership` due to previous error
|
||||
error: could not compile `ownership` (bin "ownership") due to 1 previous error
|
||||
|
|
|
@ -18,6 +18,6 @@ fn main() {
|
|||
|
||||
s.clear(); // error!
|
||||
|
||||
println!("the first word is: {}", word);
|
||||
println!("the first word is: {word}");
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
|
|
|
@ -8,9 +8,9 @@ struct User {
|
|||
// ANCHOR: here
|
||||
fn main() {
|
||||
let user1 = User {
|
||||
email: String::from("someone@example.com"),
|
||||
username: String::from("someusername123"),
|
||||
active: true,
|
||||
username: String::from("someusername123"),
|
||||
email: String::from("someone@example.com"),
|
||||
sign_in_count: 1,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ struct User {
|
|||
// ANCHOR: here
|
||||
fn main() {
|
||||
let mut user1 = User {
|
||||
email: String::from("someone@example.com"),
|
||||
username: String::from("someusername123"),
|
||||
active: true,
|
||||
username: String::from("someusername123"),
|
||||
email: String::from("someone@example.com"),
|
||||
sign_in_count: 1,
|
||||
};
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ struct User {
|
|||
// ANCHOR: here
|
||||
fn build_user(email: String, username: String) -> User {
|
||||
User {
|
||||
email: email,
|
||||
username: username,
|
||||
active: true,
|
||||
username: username,
|
||||
email: email,
|
||||
sign_in_count: 1,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ struct User {
|
|||
// ANCHOR: here
|
||||
fn build_user(email: String, username: String) -> User {
|
||||
User {
|
||||
email,
|
||||
username,
|
||||
active: true,
|
||||
username,
|
||||
email,
|
||||
sign_in_count: 1,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ error[E0277]: `Rectangle` doesn't implement `std::fmt::Display`
|
|||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `Rectangle`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `rectangles` due to previous error
|
||||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error
|
||||
|
|
|
@ -10,5 +10,5 @@ fn main() {
|
|||
height: 50,
|
||||
};
|
||||
|
||||
println!("rect1 is {:?}", rect1);
|
||||
println!("rect1 is {rect1:?}");
|
||||
}
|
||||
|
|
|
@ -28,4 +28,4 @@ help: consider introducing a named lifetime parameter
|
|||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
error: could not compile `structs` due to 2 previous errors
|
||||
error: could not compile `structs` (bin "structs") due to 2 previous errors
|
||||
|
|
|
@ -2,8 +2,8 @@ $ cargo run
|
|||
Compiling rectangles v0.1.0 (file:///projects/rectangles)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.61s
|
||||
Running `target/debug/rectangles`
|
||||
[src/main.rs:10] 30 * scale = 60
|
||||
[src/main.rs:14] &rect1 = Rectangle {
|
||||
[src/main.rs:10:16] 30 * scale = 60
|
||||
[src/main.rs:14:5] &rect1 = Rectangle {
|
||||
width: 60,
|
||||
height: 50,
|
||||
}
|
||||
|
|
|
@ -8,11 +8,12 @@ error[E0277]: `Rectangle` doesn't implement `Debug`
|
|||
|
|
||||
= help: the trait `Debug` is not implemented for `Rectangle`
|
||||
= note: add `#[derive(Debug)]` to `Rectangle` or manually `impl Debug for Rectangle`
|
||||
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: consider annotating `Rectangle` with `#[derive(Debug)]`
|
||||
|
|
||||
1 | #[derive(Debug)]
|
||||
1 + #[derive(Debug)]
|
||||
2 | struct Rectangle {
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `rectangles` due to previous error
|
||||
error: could not compile `rectangles` (bin "rectangles") due to 1 previous error
|
||||
|
|
|
@ -10,5 +10,5 @@ fn main() {
|
|||
height: 50,
|
||||
};
|
||||
|
||||
println!("rect1 is {:#?}", rect1);
|
||||
println!("rect1 is {rect1:#?}");
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ fn main() {
|
|||
// ANCHOR: here
|
||||
let config_max = Some(3u8);
|
||||
match config_max {
|
||||
Some(max) => println!("The maximum is configured to be {}", max),
|
||||
Some(max) => println!("The maximum is configured to be {max}"),
|
||||
_ => (),
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
|
|
|
@ -8,15 +8,10 @@ error[E0277]: cannot add `Option<i8>` to `i8`
|
|||
|
|
||||
= help: the trait `Add<Option<i8>>` is not implemented for `i8`
|
||||
= help: the following other types implement trait `Add<Rhs>`:
|
||||
<&'a f32 as Add<f32>>
|
||||
<&'a f64 as Add<f64>>
|
||||
<&'a i128 as Add<i128>>
|
||||
<&'a i16 as Add<i16>>
|
||||
<&'a i32 as Add<i32>>
|
||||
<&'a i64 as Add<i64>>
|
||||
<i8 as Add>
|
||||
<i8 as Add<&i8>>
|
||||
<&'a i8 as Add<i8>>
|
||||
<&'a isize as Add<isize>>
|
||||
and 48 others
|
||||
<&i8 as Add<&i8>>
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `enums` due to previous error
|
||||
error: could not compile `enums` (bin "enums") due to 1 previous error
|
||||
|
|
|
@ -19,7 +19,7 @@ fn value_in_cents(coin: Coin) -> u8 {
|
|||
Coin::Nickel => 5,
|
||||
Coin::Dime => 10,
|
||||
Coin::Quarter(state) => {
|
||||
println!("State quarter from {:?}!", state);
|
||||
println!("State quarter from {state:?}!");
|
||||
25
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
$ cargo run
|
||||
Compiling enums v0.1.0 (file:///projects/enums)
|
||||
error[E0004]: non-exhaustive patterns: `None` not covered
|
||||
--> src/main.rs:3:15
|
||||
|
|
||||
3 | match x {
|
||||
| ^ pattern `None` not covered
|
||||
|
|
||||
--> src/main.rs:3:15
|
||||
|
|
||||
3 | match x {
|
||||
| ^ pattern `None` not covered
|
||||
|
|
||||
note: `Option<i32>` defined here
|
||||
= note: the matched value is of type `Option<i32>`
|
||||
--> /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:570:1
|
||||
::: /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/option.rs:574:5
|
||||
|
|
||||
= note: not covered
|
||||
= note: the matched value is of type `Option<i32>`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
||||
|
|
||||
4 ~ Some(i) => Some(i + 1),
|
||||
5 ~ None => todo!(),
|
||||
|
|
||||
|
|
||||
4 ~ Some(i) => Some(i + 1),
|
||||
5 ~ None => todo!(),
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
||||
error: could not compile `enums` due to previous error
|
||||
error: could not compile `enums` (bin "enums") due to 1 previous error
|
||||
|
|
|
@ -2,7 +2,7 @@ fn main() {
|
|||
// ANCHOR: here
|
||||
let config_max = Some(3u8);
|
||||
if let Some(max) = config_max {
|
||||
println!("The maximum is configured to be {}", max);
|
||||
println!("The maximum is configured to be {max}");
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ fn main() {
|
|||
// ANCHOR: here
|
||||
let mut count = 0;
|
||||
match coin {
|
||||
Coin::Quarter(state) => println!("State quarter from {:?}!", state),
|
||||
Coin::Quarter(state) => println!("State quarter from {state:?}!"),
|
||||
_ => count += 1,
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
|
|
|
@ -17,7 +17,7 @@ fn main() {
|
|||
// ANCHOR: here
|
||||
let mut count = 0;
|
||||
if let Coin::Quarter(state) = coin {
|
||||
println!("State quarter from {:?}!", state);
|
||||
println!("State quarter from {state:?}!");
|
||||
} else {
|
||||
count += 1;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ error[E0603]: module `hosting` is private
|
|||
--> src/lib.rs:9:28
|
||||
|
|
||||
9 | crate::front_of_house::hosting::add_to_waitlist();
|
||||
| ^^^^^^^ private module
|
||||
| ^^^^^^^ --------------- function `add_to_waitlist` is not publicly re-exported
|
||||
| |
|
||||
| private module
|
||||
|
|
||||
note: the module `hosting` is defined here
|
||||
--> src/lib.rs:2:5
|
||||
|
@ -16,7 +18,9 @@ error[E0603]: module `hosting` is private
|
|||
--> src/lib.rs:12:21
|
||||
|
|
||||
12 | front_of_house::hosting::add_to_waitlist();
|
||||
| ^^^^^^^ private module
|
||||
| ^^^^^^^ --------------- function `add_to_waitlist` is not publicly re-exported
|
||||
| |
|
||||
| private module
|
||||
|
|
||||
note: the module `hosting` is defined here
|
||||
--> src/lib.rs:2:5
|
||||
|
@ -25,4 +29,4 @@ note: the module `hosting` is defined here
|
|||
| ^^^^^^^^^^^
|
||||
|
||||
For more information about this error, try `rustc --explain E0603`.
|
||||
error: could not compile `restaurant` due to 2 previous errors
|
||||
error: could not compile `restaurant` (lib) due to 2 previous errors
|
||||
|
|
|
@ -25,4 +25,4 @@ note: the function `add_to_waitlist` is defined here
|
|||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
For more information about this error, try `rustc --explain E0603`.
|
||||
error: could not compile `restaurant` due to 2 previous errors
|
||||
error: could not compile `restaurant` (lib) due to 2 previous errors
|
||||
|
|
|
@ -5,6 +5,11 @@ error[E0433]: failed to resolve: use of undeclared crate or module `hosting`
|
|||
|
|
||||
11 | hosting::add_to_waitlist();
|
||||
| ^^^^^^^ use of undeclared crate or module `hosting`
|
||||
|
|
||||
help: consider importing this module through its public re-export
|
||||
|
|
||||
10 + use crate::hosting;
|
||||
|
|
||||
|
||||
warning: unused import: `crate::front_of_house::hosting`
|
||||
--> src/lib.rs:7:5
|
||||
|
@ -16,4 +21,4 @@ warning: unused import: `crate::front_of_house::hosting`
|
|||
|
||||
For more information about this error, try `rustc --explain E0433`.
|
||||
warning: `restaurant` (lib) generated 1 warning
|
||||
error: could not compile `restaurant` due to previous error; 1 warning emitted
|
||||
error: could not compile `restaurant` (lib) due to 1 previous error; 1 warning emitted
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -4,4 +4,4 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.3"
|
||||
rand = "0.8.5"
|
||||
|
|
|
@ -4,5 +4,5 @@ pub mod garden;
|
|||
|
||||
fn main() {
|
||||
let plant = Asparagus {};
|
||||
println!("I'm growing {:?}!", plant);
|
||||
println!("I'm growing {plant:?}!");
|
||||
}
|
||||
|
|
|
@ -3,11 +3,11 @@ fn main() {
|
|||
let v = vec![1, 2, 3, 4, 5];
|
||||
|
||||
let third: &i32 = &v[2];
|
||||
println!("The third element is {}", third);
|
||||
println!("The third element is {third}");
|
||||
|
||||
let third: Option<&i32> = v.get(2);
|
||||
match third {
|
||||
Some(third) => println!("The third element is {}", third),
|
||||
Some(third) => println!("The third element is {third}"),
|
||||
None => println!("There is no third element."),
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
|
|
|
@ -5,12 +5,12 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immuta
|
|||
|
|
||||
4 | let first = &v[0];
|
||||
| - immutable borrow occurs here
|
||||
5 |
|
||||
5 |
|
||||
6 | v.push(6);
|
||||
| ^^^^^^^^^ mutable borrow occurs here
|
||||
7 |
|
||||
8 | println!("The first element is: {}", first);
|
||||
| ----- immutable borrow later used here
|
||||
7 |
|
||||
8 | println!("The first element is: {first}");
|
||||
| ------- immutable borrow later used here
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
||||
error: could not compile `collections` due to previous error
|
||||
error: could not compile `collections` (bin "collections") due to 1 previous error
|
||||
|
|
|
@ -6,6 +6,6 @@ fn main() {
|
|||
|
||||
v.push(6);
|
||||
|
||||
println!("The first element is: {}", first);
|
||||
println!("The first element is: {first}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ fn main() {
|
|||
// ANCHOR: here
|
||||
let v = vec![100, 32, 57];
|
||||
for i in &v {
|
||||
println!("{}", i);
|
||||
println!("{i}");
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ fn main() {
|
|||
let hello = String::from("السلام عليكم");
|
||||
let hello = String::from("Dobrý den");
|
||||
let hello = String::from("Hello");
|
||||
let hello = String::from("שָׁלוֹם");
|
||||
let hello = String::from("שלום");
|
||||
let hello = String::from("नमस्ते");
|
||||
let hello = String::from("こんにちは");
|
||||
let hello = String::from("안녕하세요");
|
||||
|
|
|
@ -3,6 +3,6 @@ fn main() {
|
|||
let mut s1 = String::from("foo");
|
||||
let s2 = "bar";
|
||||
s1.push_str(s2);
|
||||
println!("s2 is {}", s2);
|
||||
println!("s2 is {s2}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
$ cargo run
|
||||
Compiling collections v0.1.0 (file:///projects/collections)
|
||||
error[E0277]: the type `String` cannot be indexed by `{integer}`
|
||||
--> src/main.rs:3:13
|
||||
--> src/main.rs:3:16
|
||||
|
|
||||
3 | let h = s1[0];
|
||||
| ^^^^^ `String` cannot be indexed by `{integer}`
|
||||
| ^ `String` cannot be indexed by `{integer}`
|
||||
|
|
||||
= help: the trait `Index<{integer}>` is not implemented for `String`
|
||||
= help: the following other types implement trait `Index<Idx>`:
|
||||
<String as Index<RangeFrom<usize>>>
|
||||
<String as Index<RangeFull>>
|
||||
<String as Index<RangeInclusive<usize>>>
|
||||
<String as Index<RangeTo<usize>>>
|
||||
<String as Index<RangeToInclusive<usize>>>
|
||||
<String as Index<std::ops::Range<usize>>>
|
||||
<str as Index<I>>
|
||||
<String as Index<RangeFrom<usize>>>
|
||||
<String as Index<RangeTo<usize>>>
|
||||
<String as Index<RangeInclusive<usize>>>
|
||||
<String as Index<RangeToInclusive<usize>>>
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `collections` due to previous error
|
||||
error: could not compile `collections` (bin "collections") due to 1 previous error
|
||||
|
|
|
@ -7,6 +7,6 @@ fn main() {
|
|||
scores.insert(String::from("Blue"), 10);
|
||||
scores.insert(String::from("Blue"), 25);
|
||||
|
||||
println!("{:?}", scores);
|
||||
println!("{scores:?}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ fn main() {
|
|||
scores.entry(String::from("Yellow")).or_insert(50);
|
||||
scores.entry(String::from("Blue")).or_insert(50);
|
||||
|
||||
println!("{:?}", scores);
|
||||
println!("{scores:?}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -11,6 +11,6 @@ fn main() {
|
|||
*count += 1;
|
||||
}
|
||||
|
||||
println!("{:?}", map);
|
||||
println!("{map:?}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@ fn main() {
|
|||
let s2 = String::from("tac");
|
||||
let s3 = String::from("toe");
|
||||
|
||||
let s = format!("{}-{}-{}", s1, s2, s3);
|
||||
let s = format!("{s1}-{s2}-{s3}");
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ fn main() {
|
|||
scores.insert(String::from("Yellow"), 50);
|
||||
|
||||
for (key, value) in &scores {
|
||||
println!("{}: {}", key, value);
|
||||
println!("{key}: {value}");
|
||||
}
|
||||
// ANCHOR_END: here
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@ $ cargo run
|
|||
Compiling collections v0.1.0 (file:///projects/collections)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.43s
|
||||
Running `target/debug/collections`
|
||||
thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', library/core/src/str/mod.rs:127:5
|
||||
thread 'main' panicked at src/main.rs:4:19:
|
||||
byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -2,5 +2,6 @@ $ cargo run
|
|||
Compiling panic v0.1.0 (file:///projects/panic)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
|
||||
Running `target/debug/panic`
|
||||
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', src/main.rs:4:5
|
||||
thread 'main' panicked at src/main.rs:4:6:
|
||||
index out of bounds: the len is 3 but the index is 99
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -2,5 +2,6 @@ $ cargo run
|
|||
Compiling error-handling v0.1.0 (file:///projects/error-handling)
|
||||
Finished dev [unoptimized + debuginfo] target(s) in 0.73s
|
||||
Running `target/debug/error-handling`
|
||||
thread 'main' panicked at 'Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:8:23
|
||||
thread 'main' panicked at src/main.rs:8:23:
|
||||
Problem opening the file: Os { code: 2, kind: NotFound, message: "No such file or directory" }
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
|
|
@ -5,6 +5,6 @@ fn main() {
|
|||
|
||||
let greeting_file = match greeting_file_result {
|
||||
Ok(file) => file,
|
||||
Err(error) => panic!("Problem opening the file: {:?}", error),
|
||||
Err(error) => panic!("Problem opening the file: {error:?}"),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ fn main() {
|
|||
Err(error) => match error.kind() {
|
||||
ErrorKind::NotFound => match File::create("hello.txt") {
|
||||
Ok(fc) => fc,
|
||||
Err(e) => panic!("Problem creating the file: {:?}", e),
|
||||
Err(e) => panic!("Problem creating the file: {e:?}"),
|
||||
},
|
||||
other_error => {
|
||||
panic!("Problem opening the file: {:?}", other_error);
|
||||
panic!("Problem opening the file: {other_error:?}");
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// ANCHOR: here
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
use std::io::{self, Read};
|
||||
|
||||
fn read_username_from_file() -> Result<String, io::Error> {
|
||||
let mut username_file = File::open("hello.txt")?;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// ANCHOR: here
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
use std::io::{self, Read};
|
||||
|
||||
fn read_username_from_file() -> Result<String, io::Error> {
|
||||
let mut username = String::new();
|
||||
|
|
|
@ -3,13 +3,12 @@ $ cargo run
|
|||
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
|
||||
--> src/main.rs:4:48
|
||||
|
|
||||
3 | / fn main() {
|
||||
4 | | let greeting_file = File::open("hello.txt")?;
|
||||
| | ^ cannot use the `?` operator in a function that returns `()`
|
||||
5 | | }
|
||||
| |_- this function should return `Result` or `Option` to accept `?`
|
||||
3 | fn main() {
|
||||
| --------- this function should return `Result` or `Option` to accept `?`
|
||||
4 | let greeting_file = File::open("hello.txt")?;
|
||||
| ^ cannot use the `?` operator in a function that returns `()`
|
||||
|
|
||||
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
error: could not compile `error-handling` due to previous error
|
||||
error: could not compile `error-handling` (bin "error-handling") due to 1 previous error
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -38,14 +40,13 @@ checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
|
|||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -67,15 +68,6 @@ dependencies = [
|
|||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.2+wasi-snapshot-preview1"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue