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 69
69
#![ feature( trusted_len) ]
70
70
#![ feature( vec_remove_item) ]
71
71
#![ feature( catch_expr) ]
72
+ #![ feature( step_trait) ]
72
73
#![ feature( integer_atomics) ]
73
74
#![ feature( test) ]
74
75
#![ feature( in_band_lifetimes) ]
Original file line number Diff line number Diff line change @@ -89,6 +89,35 @@ macro_rules! newtype_index {
89
89
}
90
90
}
91
91
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
+
92
121
newtype_index!(
93
122
@handle_debug
94
123
@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!
36
36
#![ feature( specialization) ]
37
37
#![ feature( try_trait) ]
38
38
#![ feature( unicode_internals) ]
39
+ #![ feature( step_trait) ]
39
40
40
41
#![ recursion_limit="256" ]
41
42
You can’t perform that action at this time.
0 commit comments