@@ -18,7 +18,7 @@ impl CharSet {
18
18
}
19
19
20
20
pub fn insert ( & mut self , char : char ) {
21
- let val = char as uint - 1 ;
21
+ let val = char as u32 - 1 ;
22
22
23
23
if val > 127 {
24
24
self . non_ascii . insert ( char) ;
@@ -32,7 +32,7 @@ impl CharSet {
32
32
}
33
33
34
34
pub fn contains ( & self , char : char ) -> bool {
35
- let val = char as uint - 1 ;
35
+ let val = char as u32 - 1 ;
36
36
37
37
if val > 127 {
38
38
self . non_ascii . contains ( & char)
@@ -67,7 +67,7 @@ impl CharacterClass {
67
67
}
68
68
69
69
pub fn valid_char ( char : char ) -> CharacterClass {
70
- let val = char as uint - 1 ;
70
+ let val = char as u32 - 1 ;
71
71
72
72
if val > 127 {
73
73
ValidChars ( CharacterClass :: char_to_set ( char) )
@@ -79,7 +79,7 @@ impl CharacterClass {
79
79
}
80
80
81
81
pub fn invalid_char ( char : char ) -> CharacterClass {
82
- let val = char as uint - 1 ;
82
+ let val = char as u32 - 1 ;
83
83
84
84
if val > 127 {
85
85
InvalidChars ( CharacterClass :: char_to_set ( char) )
@@ -96,7 +96,7 @@ impl CharacterClass {
96
96
ValidChars ( ref valid) => valid. contains ( char) ,
97
97
InvalidChars ( ref invalid) => !invalid. contains ( char) ,
98
98
Ascii ( high, low, unicode) => {
99
- let val = char as uint - 1 ;
99
+ let val = char as u32 - 1 ;
100
100
if val > 127 {
101
101
unicode
102
102
} else if val > 63 {
@@ -125,9 +125,9 @@ impl CharacterClass {
125
125
126
126
#[ derive( Clone ) ]
127
127
struct Thread {
128
- state : uint ,
129
- captures : Vec < ( uint , uint ) > ,
130
- capture_begin : Option < uint >
128
+ state : usize ,
129
+ captures : Vec < ( usize , usize ) > ,
130
+ capture_begin : Option < usize >
131
131
}
132
132
133
133
impl Thread {
@@ -136,12 +136,12 @@ impl Thread {
136
136
}
137
137
138
138
#[ inline]
139
- pub fn start_capture ( & mut self , start : uint ) {
139
+ pub fn start_capture ( & mut self , start : usize ) {
140
140
self . capture_begin = Some ( start) ;
141
141
}
142
142
143
143
#[ inline]
144
- pub fn end_capture ( & mut self , end : uint ) {
144
+ pub fn end_capture ( & mut self , end : usize ) {
145
145
self . captures . push ( ( self . capture_begin . unwrap ( ) , end) ) ;
146
146
self . capture_begin = None ;
147
147
}
@@ -153,9 +153,9 @@ impl Thread {
153
153
154
154
#[ derive( Clone ) ]
155
155
pub struct State < T > {
156
- pub index : uint ,
156
+ pub index : usize ,
157
157
pub chars : CharacterClass ,
158
- pub next_states : Vec < uint > ,
158
+ pub next_states : Vec < usize > ,
159
159
pub acceptance : bool ,
160
160
pub start_capture : bool ,
161
161
pub end_capture : bool ,
@@ -169,7 +169,7 @@ impl<T> PartialEq for State<T> {
169
169
}
170
170
171
171
impl < T > State < T > {
172
- pub fn new ( index : uint , chars : CharacterClass ) -> State < T > {
172
+ pub fn new ( index : usize , chars : CharacterClass ) -> State < T > {
173
173
State {
174
174
index : index,
175
175
chars : chars,
@@ -183,12 +183,12 @@ impl<T> State<T> {
183
183
}
184
184
185
185
pub struct Match < ' a > {
186
- pub state : uint ,
186
+ pub state : usize ,
187
187
pub captures : Vec < & ' a str > ,
188
188
}
189
189
190
190
impl < ' a > Match < ' a > {
191
- pub fn new < ' b > ( state : uint , captures : Vec < & ' b str > ) -> Match < ' b > {
191
+ pub fn new < ' b > ( state : usize , captures : Vec < & ' b str > ) -> Match < ' b > {
192
192
Match { state : state, captures : captures }
193
193
}
194
194
}
@@ -214,7 +214,7 @@ impl<T> NFA<T> {
214
214
215
215
pub fn process < ' a , I , F > ( & self , string : & ' a str , mut ord : F )
216
216
-> Result < Match < ' a > , String >
217
- where I : Ord , F : FnMut ( uint ) -> I
217
+ where I : Ord , F : FnMut ( usize ) -> I
218
218
{
219
219
let mut threads = vec ! [ Thread :: new( ) ] ;
220
220
@@ -249,13 +249,13 @@ impl<T> NFA<T> {
249
249
250
250
#[ inline]
251
251
fn process_char < ' a > ( & self , threads : Vec < Thread > ,
252
- char : char , pos : uint ) -> Vec < Thread > {
252
+ char : char , pos : usize ) -> Vec < Thread > {
253
253
let mut returned = Vec :: with_capacity ( threads. len ( ) ) ;
254
254
255
255
for mut thread in threads. into_iter ( ) {
256
256
let current_state = self . get ( thread. state ) ;
257
257
258
- let mut count = 0 i ;
258
+ let mut count = 0 ;
259
259
let mut found_state = 0 ;
260
260
261
261
for & index in current_state. next_states . iter ( ) {
@@ -289,15 +289,15 @@ impl<T> NFA<T> {
289
289
}
290
290
291
291
#[ inline]
292
- pub fn get < ' a > ( & ' a self , state : uint ) -> & ' a State < T > {
292
+ pub fn get < ' a > ( & ' a self , state : usize ) -> & ' a State < T > {
293
293
& self . states [ state]
294
294
}
295
295
296
- pub fn get_mut < ' a > ( & ' a mut self , state : uint ) -> & ' a mut State < T > {
296
+ pub fn get_mut < ' a > ( & ' a mut self , state : usize ) -> & ' a mut State < T > {
297
297
& mut self . states [ state]
298
298
}
299
299
300
- pub fn put ( & mut self , index : uint , chars : CharacterClass ) -> uint {
300
+ pub fn put ( & mut self , index : usize , chars : CharacterClass ) -> usize {
301
301
{
302
302
let state = self . get ( index) ;
303
303
@@ -314,32 +314,32 @@ impl<T> NFA<T> {
314
314
state
315
315
}
316
316
317
- pub fn put_state ( & mut self , index : uint , child : uint ) {
317
+ pub fn put_state ( & mut self , index : usize , child : usize ) {
318
318
if !self . states [ index] . next_states . contains ( & child) {
319
319
self . get_mut ( index) . next_states . push ( child) ;
320
320
}
321
321
}
322
322
323
- pub fn acceptance ( & mut self , index : uint ) {
323
+ pub fn acceptance ( & mut self , index : usize ) {
324
324
self . get_mut ( index) . acceptance = true ;
325
325
self . acceptance [ index] = true ;
326
326
}
327
327
328
- pub fn start_capture ( & mut self , index : uint ) {
328
+ pub fn start_capture ( & mut self , index : usize ) {
329
329
self . get_mut ( index) . start_capture = true ;
330
330
self . start_capture [ index] = true ;
331
331
}
332
332
333
- pub fn end_capture ( & mut self , index : uint ) {
333
+ pub fn end_capture ( & mut self , index : usize ) {
334
334
self . get_mut ( index) . end_capture = true ;
335
335
self . end_capture [ index] = true ;
336
336
}
337
337
338
- pub fn metadata ( & mut self , index : uint , metadata : T ) {
338
+ pub fn metadata ( & mut self , index : usize , metadata : T ) {
339
339
self . get_mut ( index) . metadata = Some ( metadata) ;
340
340
}
341
341
342
- fn new_state ( & mut self , chars : CharacterClass ) -> uint {
342
+ fn new_state ( & mut self , chars : CharacterClass ) -> usize {
343
343
let index = self . states . len ( ) ;
344
344
let state = State :: new ( index, chars) ;
345
345
self . states . push ( state) ;
@@ -360,7 +360,8 @@ fn fork_thread<T>(thread: &Thread, state: &State<T>) -> Thread {
360
360
}
361
361
362
362
#[ inline]
363
- fn capture < T > ( nfa : & NFA < T > , thread : & mut Thread , current_state : uint , next_state : uint , pos : uint ) {
363
+ fn capture < T > ( nfa : & NFA < T > , thread : & mut Thread , current_state : usize ,
364
+ next_state : usize , pos : usize ) {
364
365
if thread. capture_begin == None && nfa. start_capture [ next_state] {
365
366
thread. start_capture ( pos) ;
366
367
}
0 commit comments