diff options
| author | Jonas Böttiger <jonas.boettiger@icloud.com> | 2024-12-09 13:22:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-09 13:22:39 +0100 |
| commit | 13c77ba34d16255d9f5a57758140c73a86f1895c (patch) | |
| tree | 507744d694993717859437698594f0611b0e1e78 | |
| parent | 69942f01328629764558afc0e4754cdf6f663e5a (diff) | |
| download | rust-13c77ba34d16255d9f5a57758140c73a86f1895c.tar.gz rust-13c77ba34d16255d9f5a57758140c73a86f1895c.zip | |
core: improve comments
Co-authored-by: Yotam Ofek <yotam.ofek@gmail.com> Co-authored-by: Hanna Kruppe <hanna.kruppe@gmail.com>
| -rw-r--r-- | library/core/src/bool.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/library/core/src/bool.rs b/library/core/src/bool.rs index b9590dcc1e7..5c9b0e28106 100644 --- a/library/core/src/bool.rs +++ b/library/core/src/bool.rs @@ -62,12 +62,14 @@ impl bool { } /// Returns either `true_val` or `false_val` depending on the value of - /// `condition`, with a hint to the compiler that `condition` is unlikely + /// `self`, with a hint to the compiler that `self` is unlikely /// to be correctly predicted by a CPU’s branch predictor. /// - /// This method is functionally equivalent to writing + /// This method is functionally equivalent to /// ```ignore (this is just for illustrative purposes) - /// if b { true_val } else { false_val } + /// fn select_unpredictable<T>(b: bool, true_val: T, false_val: T) -> T { + /// if b { true_val } else { false_val } + /// } /// ``` /// but might generate different assembly. In particular, on platforms with /// a conditional move or select instruction (like `cmov` on x86 or `csel` |
