Skip to content

Commit d6edde3

Browse files
committed
SAFETY comments
1 parent 3ecc882 commit d6edde3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/runtime/timer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub fn state() -> TimerState {
119119
/// So you need to be careful when using this value for indexing.
120120
/// Same index does not imply same split on undo and then split.
121121
pub fn current_split_index() -> Option<u64> {
122+
// SAFETY: It is always safe to call this function.
122123
let i = unsafe { sys::timer_current_split_index() };
123124
if i.is_negative() {
124125
return None;
@@ -132,6 +133,10 @@ pub fn current_split_index() -> Option<u64> {
132133
/// If `idx` is greater than or equal to the current split index,
133134
/// `None` is returned instead.
134135
pub fn segment_splitted(idx: u64) -> Option<bool> {
136+
// SAFETY: It is always safe to call this function.
137+
// Even when `idx` is out of bounds,
138+
// timer_segment_splitted returns `-1`,
139+
// and then segment_splitted returns `None`.
135140
match unsafe { sys::timer_segment_splitted(idx) } {
136141
1 => Some(true),
137142
0 => Some(false),

0 commit comments

Comments
 (0)