File tree 1 file changed +24
-7
lines changed
1 file changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -20,20 +20,37 @@ enum Color {
20
20
White = 15 ,
21
21
}
22
22
23
- fn range ( lo : uint , hi : uint , it: |uint| -> ( ) ) {
24
- let mut iter = lo;
25
- while iter < hi {
26
- it ( iter) ;
27
- iter += 1 ;
23
+ enum Option < T > {
24
+ None ,
25
+ Some ( T )
26
+ }
27
+
28
+ struct IntRange {
29
+ cur : int ,
30
+ max : int
31
+ }
32
+
33
+ impl IntRange {
34
+ fn next ( & mut self ) -> Option < int > {
35
+ if self . cur < self . max {
36
+ self . cur += 1 ;
37
+ Some ( self . cur - 1 )
38
+ } else {
39
+ None
40
+ }
28
41
}
29
42
}
30
43
44
+ fn range ( lo : int , hi : int ) -> IntRange {
45
+ IntRange { cur : lo, max : hi }
46
+ }
47
+
31
48
fn clear_screen ( background : Color ) {
32
- range ( 0 , 80 * 25 , |i| {
49
+ for i in range ( 0 , 80 * 25 ) {
33
50
unsafe {
34
51
* ( ( 0xb8000 + i * 2 ) as * mut u16 ) = ( background as u16 ) << 12 ;
35
52
}
36
- } ) ;
53
+ }
37
54
}
38
55
39
56
#[ no_mangle]
You can’t perform that action at this time.
0 commit comments