Skip to content

Commit 5dd1390

Browse files
authored
Use unconst instead of unsafe
1 parent 67d5916 commit 5dd1390

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

const_safety.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ some extensions of the miri engine that are already implemented in miri) even
114114
though it uses raw pointer operations:
115115
```rust
116116
const fn test_eq<T>(x: &T, y: &T) -> bool {
117-
unsafe { x as *const _ == y as *const _ }
117+
unconst { x as *const _ == y as *const _ }
118118
}
119119
```
120120
On the other hand, the following function is *not* const-safe and hence it is considered a bug to mark it as such:
121121
```
122122
const fn convert<T>(x: &T) -> usize {
123-
unsafe { x as *const _ as usize }
123+
unconst { x as *const _ as usize }
124124
}
125125
```
126126

0 commit comments

Comments
 (0)