File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed
Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 6969#![ feature( trusted_len) ]
7070#![ feature( vec_remove_item) ]
7171#![ feature( catch_expr) ]
72+ #![ feature( step_trait) ]
7273#![ feature( integer_atomics) ]
7374#![ feature( test) ]
7475#![ feature( in_band_lifetimes) ]
Original file line number Diff line number Diff line change @@ -89,6 +89,35 @@ macro_rules! newtype_index {
8989 }
9090 }
9191
92+ impl :: std:: iter:: Step for $type {
93+ fn steps_between( start: & Self , end: & Self ) -> Option <usize > {
94+ <usize as :: std:: iter:: Step >:: steps_between(
95+ & Idx :: index( * start) ,
96+ & Idx :: index( * end) ,
97+ )
98+ }
99+
100+ fn replace_one( & mut self ) -> Self {
101+ :: std:: mem:: replace( self , Self :: new( 1 ) )
102+ }
103+
104+ fn replace_zero( & mut self ) -> Self {
105+ :: std:: mem:: replace( self , Self :: new( 0 ) )
106+ }
107+
108+ fn add_one( & self ) -> Self {
109+ Self :: new( Idx :: index( * self ) + 1 )
110+ }
111+
112+ fn sub_one( & self ) -> Self {
113+ Self :: new( Idx :: index( * self ) - 1 )
114+ }
115+
116+ fn add_usize( & self , u: usize ) -> Option <Self > {
117+ Idx :: index( * self ) . checked_add( u) . map( Self :: new)
118+ }
119+ }
120+
92121 newtype_index!(
93122 @handle_debug
94123 @derives [ $( $derives, ) * ]
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
3636#![ feature( specialization) ]
3737#![ feature( try_trait) ]
3838#![ feature( unicode_internals) ]
39+ #![ feature( step_trait) ]
3940
4041#![ recursion_limit="256" ]
4142
You can’t perform that action at this time.
0 commit comments