Skip to content

Update generic.md #1515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/basic/trait/generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ impl IsTrue for Assert<true> {

通常情况下,函数是在运行时被调用和执行的。然而,在某些场景下,我们希望在编译期就计算出一些值,以提高运行时的性能或满足某些编译期的约束条件。例如,定义数组的长度、计算常量值等。

有了 `const fn`,我们可以在编译期执行这些函数,从而将计算结果直接嵌入到生成的代码中。这不仅以高了运行时的性能,还使代码更加简洁和安全。
有了 `const fn`,我们可以在编译期执行这些函数,从而将计算结果直接嵌入到生成的代码中。这不仅提高了运行时的性能,还使代码更加简洁和安全。

##### const fn 的基本用法

Expand Down