Skip to content

Update error/result/enter_question_mark#6

Open
Albert9364 wants to merge 70 commits into
rust-lang-cn:zhfrom
Albert9364:master
Open

Update error/result/enter_question_mark#6
Albert9364 wants to merge 70 commits into
rust-lang-cn:zhfrom
Albert9364:master

Conversation

@Albert9364
Copy link
Copy Markdown

@Albert9364 Albert9364 commented Feb 25, 2026

原本有序号,翻译中不需要额外添加序号,否则序号会出现两遍
https://doc.rust-lang.org/rust-by-example/zh/error/result/enter_question_mark.html

dcechano and others added 30 commits January 10, 2025 00:24
I'm not sure what that meant to be initially, but this looks more useful now.
Make code more idiomatic.

A person learning Rust for the first time seeing `use crate::Role::*` gets spun into a rabbit hole of:

- understanding what "crate::" means here
- is a single file a crate? (look it up in the docs)
- do even enums local to the file have to be specified with an absolute path from crate root?

Besides, `use crate:: ...` is taught in the example for use later on, which is linked to at the bottom of this document. Using this document to only teach about unpacking enums into the name space, and then using the other document to introduce `use crate::`, means less things need to be learned all at once, reducing confusion.
Corrected a typo in the comment regarding non-tail recursion.
Fix typo in linked list length calculation comment
…atch-binding

Add an example showing pattern binding when matching several values in a match arm
Include a link to The Rust Reference in flow_control/match/destructuring
…-clarification

add clarification on overflowing_literals lint
Fix typos in flow_control/match/binding
Updated the description of the `Path` type to clarify its usage across platforms and simplified the language.

I updated src/std_misc/path.md to remove references to separate posix::Path/windows::Path and reflect that there’s a single std::path::Path. I also simplified the closing guidance to point users to Path methods and Metadata.
I added a runtime check in the language picker so unavailable locales are hidden, preventing 404s like the Spanish URL on doc.rust-lang.org. This keeps working languages (ja/zh) visible and avoids broken links when a locale isn’t deployed.

To verify locally
- English-only build: run mdbook serve and confirm the menu hides ja/zh/es.
- Japanese build: MDBOOK_BOOK__LANGUAGE=ja mdbook serve and confirm only ja (and any other deployed locales) remain.
- Spanish build: MDBOOK_BOOK__LANGUAGE=es mdbook serve and confirm es remains and others hide.
Revise `Path` type documentation for clarity
Clarify the description of the `any` function parameters.
use AND search instead of OR, which is default
I have not seen manual scoping used elsewhere before
…`-behavior-in-Iteratorany-trait-example

Update documentation for `any` function in iter_any.md
enum_use.md: avoid an uncommon term
link the _tuple_ page instead "TupleStruct"
Use `From::from` fn pointer to convert to boxed errors
… 1000" in HOF.md

The algorithm to "Find the sum of all the numbers with odd squares under 1000" is wrong. It was calculating the sum of odd squares under 1000.
marioidival and others added 30 commits January 15, 2026 11:24
added real implementation and sample main to given an idea on how to use
fixed s missing in struct
phoneNumber number is not in use and it generates a working
Previously, this example wasn't compiling because of the deprecated `thread_rng` and `fill` functions. Upon making the changes the compiler suggests and swapping `usize` for `u64`, the example compiles properly. Here are the compile errors:

```sh
Compiling playground v0.0.1 (/playground)
warning: unused import: `rand::Fill`
 --> src/main.rs:2:5
  |
2 | use rand::Fill;
  |     ^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

warning: use of deprecated function `rand::thread_rng`: Renamed to `rng`
 --> src/main.rs:5:25
  |
5 |     let mut rng = rand::thread_rng();
  |                         ^^^^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default

error[E0599]: no method named `try_fill` found for struct `Box<[{integer}; 100]>` in the current scope
 --> src/main.rs:7:11
  |
7 |     boxed.try_fill(&mut rng).unwrap();
  |           ^^^^^^^^
  |
help: there is a method `fill` with a similar name
  |
7 -     boxed.try_fill(&mut rng).unwrap();
7 +     boxed.fill(&mut rng).unwrap();
  |

For more information about this error, try `rustc --explain E0599`.
warning: `playground` (bin "playground") generated 2 warnings
error: could not compile `playground` (bin "playground") due to 1 previous error; 2 warnings emitted
```
Expanded the documentation on the Clone and Copy traits, detailing their behaviors and requirements. Added examples to illustrate implicit copying and explicit cloning.
Improve Clone and Copy traits documentation
Update deprecated functions in `Box::leak` example
From context and from the [previous PR](rust-lang@7da5b73) (which removed the space after the operator), we can see this is a typo. 😉
1.2.2 Display: Fix typo in bonus instructions (before -> after)
序号重复,原格式中有序号,翻译中有序号就会出现两遍
Show how a module can re-export an item with pub use so the use declaration chapter covers that common pattern directly.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
The into_iter() example previously used `println!("names: {:?}", names)`
after the collection was consumed, causing a compilation error. Commented
out the offending line with an explanation and removed the `ignore` flag
so the example is now compilable and runnable.
…t-lang#1925)

The comments incorrectly stated that File's drop runs before the custom
drop implementation. In Rust, the custom drop method runs first, and
then fields are dropped afterwards. Updated comments to reflect the
actual destruction order.
…e-time-fallacy

fix: replace year-to-days conversion with miles-to-km in newtype example
…ind-comments

fix: correct iter/into_iter type comments in iter_find example
…se-list-comment

fix: clarify comment about tuple struct field access in testcase_list
…display-error-comment

fix: clarify misleading 'Error' comment in print_display example
…ted-print-module-wording

fix: replace confusing 'module' with 'item' in formatted print docs
…estruction-order

fix: correct destruction order comments in Drop TempFile example
…ter-compile-error

fix: correct into_iter() example to compile properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.