| 1 | //! Hints to the compiler that affects how code should be emitted or optimized. |
| 2 | |
| 3 | #![expect( |
| 4 | dead_code, |
| 5 | reason = "may be used in the future and has minimal overhead" |
| 6 | )] |
| 7 | |
| 8 | /// Indicate that a given branch is **not** likely to be taken, relatively speaking. |
| 9 | #[inline(always)] |
| 10 | #[cold] |
| 11 | pub(craterust-analyzer cargo time-core 0.1.9 crate/) const fn cold_pathrust-analyzer cargo time-core 0.1.9 hint/cold_path().() {} |
| 12 | |
| 13 | /// Indicate that a given condition is likely to be true. |
| 14 | #[inline(always)] |
| 15 | pub(craterust-analyzer cargo time-core 0.1.9 crate/) const fn likelyrust-analyzer cargo time-core 0.1.9 hint/likely().(b: bool) -> bool { |
| 16 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().b { |
| 17 | cold_pathrust-analyzer cargo time-core 0.1.9 hint/cold_path().(); |
| 18 | } |
| 19 | b |
| 20 | } |
| 21 | |
| 22 | /// Indicate that a given condition is likely to be false. |
| 23 | #[inline(always)] |
| 24 | pub(craterust-analyzer cargo time-core 0.1.9 crate/) const fn unlikelyrust-analyzer cargo time-core 0.1.9 hint/unlikely().(b: bool) -> bool { |
| 25 | if b { |
| 26 | cold_pathrust-analyzer cargo time-core 0.1.9 hint/cold_path().(); |
| 27 | } |
| 28 | b |
| 29 | } |