@@ -112,18 +112,31 @@ pub fn state() -> TimerState {
112112 }
113113}
114114
115- /// Accesses the index of the split the attempt is currently on. If there's
116- /// no attempt in progress, `-1` is returned instead. This returns an
117- /// index that is equal to the amount of segments when the attempt is
118- /// finished, but has not been reset. So you need to be careful when using
119- /// this value for indexing.
120- pub fn current_split_index ( ) -> i32 {
121- unsafe { sys:: timer_current_split_index ( ) }
115+ /// Accesses the index of the split the attempt is currently on.
116+ /// If there's no attempt in progress, `None` is returned instead.
117+ /// This returns an index that is equal to the amount of segments
118+ /// when the attempt is finished, but has not been reset.
119+ /// So you need to be careful when using this value for indexing.
120+ /// Same index does not imply same split on undo and then split.
121+ pub fn current_split_index ( ) -> Option < u64 > {
122+ let i = unsafe { sys:: timer_current_split_index ( ) } ;
123+ if i. is_negative ( ) {
124+ return None ;
125+ }
126+ Some ( i as u64 )
122127}
123128
124129/// Whether the segment at `idx` was splitted this attempt.
125- pub fn segment_splitted ( idx : i32 ) -> bool {
126- unsafe { sys:: timer_segment_splitted ( idx) }
130+ /// Returns `Some(true)` if the segment was splitted,
131+ /// or `Some(false)` if skipped.
132+ /// If `idx` is greater than or equal to the current split index,
133+ /// `None` is returned instead.
134+ pub fn segment_splitted ( idx : u64 ) -> Option < bool > {
135+ match unsafe { sys:: timer_segment_splitted ( idx) } {
136+ 1 => Some ( true ) ,
137+ 0 => Some ( false ) ,
138+ _ => None ,
139+ }
127140}
128141
129142/// Sets the game time.
0 commit comments