Skip to content

refactor: improve readability and consistency of Rust code#1850

Open
Lingxuan-Ye wants to merge 109 commits intokrahets:mainfrom
Lingxuan-Ye:dev
Open

refactor: improve readability and consistency of Rust code#1850
Lingxuan-Ye wants to merge 109 commits intokrahets:mainfrom
Lingxuan-Ye:dev

Conversation

@Lingxuan-Ye
Copy link

If this pull request (PR) pertains to Chinese-to-English translation, please confirm that you have read the contribution guidelines and complete the checklist below:

  • This PR represents the translation of a single, complete document, or contains only bug fixes.
  • The translation accurately conveys the original meaning and intent of the Chinese version. If deviations exist, I have provided explanatory comments to clarify the reasons.

If this pull request (PR) is associated with coding or code transpilation, please attach the relevant console outputs to the PR and complete the following checklist:

  • I have thoroughly reviewed the code, focusing on its formatting, comments, indentation, and file headers.
  • I have confirmed that the code execution outputs are consistent with those produced by the reference code (Python or Java).
  • The code is designed to be compatible on standard operating systems, including Windows, macOS, and Ubuntu.

@Lingxuan-Ye
Copy link
Author

  • 修复了 4 项错误和 89 项警告;
  • 修复了大量 unsound 的类型 cast;
  • 提高了程序在合法 corner cases 下的健壮性;
  • 移除示例代码中的所有 unwrap 调用;
  • 重写了 lib hello_algo_rust 并解耦了所有 bin crates。

@rongyi
Copy link
Contributor

rongyi commented Jan 30, 2026

unwrap其实没什么,大量的加 pub 其实没必要,我觉得可以精炼一下,那些 print 主要是兼容其他语言,建议轻易不要动。否则,看几个 commit 就不想看了。

@Lingxuan-Ye
Copy link
Author

  • 其他语言使用 print 的我都没有移除 print 方法;
  • unwrap 我只是额外分析了可达性,并没有提高复杂度;
  • 关于 pub 请看我添加的维护指南
  • 我认为教程示例应该指导初学者编写正确、规范的代码,目前代码存在大量警告和 unsound 逻辑,我认为有必要修复这些。

First of all, these comments should not be doc comments because they do not document or explain any bit of the crates. Secondly, they should never be outer doc comments, as outer doc comments document items right below rather than the crates. It is just wrong.
Removed:
- `clippy::let_and_return`
Removed:
- `clippy::assign_op_pattern`
- `clippy::let_and_return`

Explicitly omitted:
- `clippy::manual_swap`
Removed:
- `clippy::needless_return`

Explicitly omitted:
- `dead_code`
- `unused_variables`
When it comes to spatial overhead, `usize` should be used.
Explicitly omitted:
- `clippy::manual_find`
-  `clippy::needless_range_loop`
Removed:
- `clippy::let_and_return`

Explicitly omitted:
- `unused_variables`
- `unused_assignments`
- `clippy::needless_range_loop`
- `clippy::manual_find`
Explicitly omitted:
- `unused_variables`
- `unused_assignments`
- `clippy::needless_range_loop`
Removed:
- `clippy::needless_return`
Explicitly omitted:
- `clippy::vec_init_then_push`
Removed:
- `clippy::needless_return`

Explicitly omitted:
- `clippy::new_without_default`
Explicitly omitted:
- `clippy::new_without_default`
@Lingxuan-Ye
Copy link
Author

重写了 git 历史以方便 review 并修改了部分不一致的代码。

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.

2 participants