@@ -28,7 +28,7 @@ pub fn create_error_correction_code(data: &[u8], ec_code_size: uint) -> Vec<u8>
2828 }
2929
3030 let log_lead_coeff = LOG_TABLE [ lead_coeff] as uint ;
31- for ( u, v) in res. slice_from_mut ( i+1 ) . iter_mut ( ) . zip ( log_den. iter ( ) ) {
31+ for ( u, v) in res[ mut i+1 .. ] . iter_mut ( ) . zip ( log_den. iter ( ) ) {
3232 * u ^= EXP_TABLE [ ( ( * v as uint + log_lead_coeff) % 255 ) as uint ] ;
3333 }
3434 }
@@ -43,19 +43,19 @@ mod ec_tests {
4343 #[ test]
4444 fn test_poly_mod_1 ( ) {
4545 let res = create_error_correction_code ( b" [\x0b x\xd1 r\xdc MC@\xec \x11 \xec \x11 \xec \x11 " , 10 ) ;
46- assert_eq ! ( res. as_slice ( ) , b"\xc4 #'w\xeb \xd7 \xe7 \xe2 ]\x17 " ) ;
46+ assert_eq ! ( res[ ] , b"\xc4 #'w\xeb \xd7 \xe7 \xe2 ]\x17 " ) ;
4747 }
4848
4949 #[ test]
5050 fn test_poly_mod_2 ( ) {
5151 let res = create_error_correction_code ( b" [\x0b x\xd1 r\xdc MC@\xec \x11 \xec " , 13 ) ;
52- assert_eq ! ( res. as_slice ( ) , b"\xa8 H\x16 R\xd9 6\x9c \x00 .\x0f \xb4 z\x10 " ) ;
52+ assert_eq ! ( res[ ] , b"\xa8 H\x16 R\xd9 6\x9c \x00 .\x0f \xb4 z\x10 " ) ;
5353 }
5454
5555 #[ test]
5656 fn test_poly_mod_3 ( ) {
5757 let res = create_error_correction_code ( b"CUF\x86 W&U\xc2 w2\x06 \x12 \x06 g&" , 18 ) ;
58- assert_eq ! ( res. as_slice ( ) , b"\xd5 \xc7 \x0b -s\xf7 \xf1 \xdf \xe5 \xf8 \x9a u\x9a oV\xa1 o'" ) ;
58+ assert_eq ! ( res[ ] , b"\xd5 \xc7 \x0b -s\xf7 \xf1 \xdf \xe5 \xf8 \x9a u\x9a oV\xa1 o'" ) ;
5959 }
6060}
6161
@@ -118,7 +118,7 @@ fn interleave<T: Copy, V>(blocks: &Vec<V>) -> Vec<T>
118118#[ test]
119119fn test_interleave ( ) {
120120 let res = interleave ( & vec ! [ b"1234" , b"5678" , b"abcdef" , b"ghijkl" ] ) ;
121- assert_eq ! ( res. as_slice ( ) , b"15ag26bh37ci48djekfl" ) ;
121+ assert_eq ! ( res[ ] , b"15ag26bh37ci48djekfl" ) ;
122122}
123123
124124//}}}
@@ -131,7 +131,7 @@ pub fn construct_codewords(rawbits: &[u8],
131131 version : QrVersion ,
132132 ec_level : ErrorCorrectionLevel ) -> QrResult < ( Vec < u8 > , Vec < u8 > ) > {
133133 let ( block_1_size, block_1_count, block_2_size, block_2_count) =
134- try!( version. fetch ( ec_level, DATA_BYTES_PER_BLOCK . as_slice ( ) ) ) ;
134+ try!( version. fetch ( ec_level, DATA_BYTES_PER_BLOCK [ ] ) ) ;
135135
136136 let blocks_count = block_1_count + block_2_count;
137137 let block_1_end = block_1_size * block_1_count;
@@ -141,13 +141,13 @@ pub fn construct_codewords(rawbits: &[u8],
141141
142142 // Divide the data into blocks.
143143 let mut blocks = Vec :: with_capacity ( blocks_count) ;
144- blocks. extend ( rawbits. slice_to ( block_1_end) . chunks ( block_1_size) ) ;
144+ blocks. extend ( rawbits[ .. block_1_end] . chunks ( block_1_size) ) ;
145145 if block_2_size > 0 {
146- blocks. extend ( rawbits. slice_from ( block_1_end) . chunks ( block_2_size) ) ;
146+ blocks. extend ( rawbits[ block_1_end.. ] . chunks ( block_2_size) ) ;
147147 }
148148
149149 // Generate EC codes.
150- let ec_bytes = try!( version. fetch ( ec_level, EC_BYTES_PER_BLOCK . as_slice ( ) ) ) ;
150+ let ec_bytes = try!( version. fetch ( ec_level, EC_BYTES_PER_BLOCK [ ] ) ) ;
151151 let ec_codes = blocks. iter ( )
152152 . map ( |block| create_error_correction_code ( * block, ec_bytes) )
153153 . collect :: < Vec < Vec < u8 > > > ( ) ;
@@ -167,17 +167,17 @@ mod construct_codewords_test {
167167 fn test_add_ec_simple ( ) {
168168 let msg = b" [\x0b x\xd1 r\xdc MC@\xec \x11 \xec \x11 \xec \x11 " ;
169169 let ( blocks_vec, ec_vec) = construct_codewords ( msg, Version ( 1 ) , M ) . unwrap ( ) ;
170- assert_eq ! ( blocks_vec. as_slice ( ) , msg) ;
171- assert_eq ! ( ec_vec. as_slice ( ) , b"\xc4 #'w\xeb \xd7 \xe7 \xe2 ]\x17 " ) ;
170+ assert_eq ! ( blocks_vec[ ] , msg) ;
171+ assert_eq ! ( ec_vec[ ] , b"\xc4 #'w\xeb \xd7 \xe7 \xe2 ]\x17 " ) ;
172172 }
173173
174174 #[ test]
175175 fn test_add_ec_complex ( ) {
176176 let msg = b"CUF\x86 W&U\xc2 w2\x06 \x12 \x06 g&\xf6 \xf6 B\x07 v\x86 \xf2 \x07 &V\x16 \xc6 \xc7 \x92 \x06 \xb6 \xe6 \xf7 w2\x07 v\x86 W&R\x06 \x86 \x97 2\x07 F\xf7 vV\xc2 \x06 \x97 2\x10 \xec \x11 \xec \x11 \xec \x11 \xec " ;
177177 let ( blocks_vec, ec_vec) = construct_codewords ( msg, Version ( 5 ) , Q ) . unwrap ( ) ;
178- assert_eq ! ( blocks_vec. as_slice ( ) ,
178+ assert_eq ! ( blocks_vec[ ] ,
179179 b"C\xf6 \xb6 FU\xf6 \xe6 \xf7 FB\xf7 v\x86 \x07 wVWv2\xc2 &\x86 \x07 \x06 U\xf2 v\x97 \xc2 \x07 \x86 2w&W\x10 2V&\xec \x06 \x16 R\x11 \x12 \xc6 \x06 \xec \x06 \xc7 \x86 \x11 g\x92 \x97 \xec &\x06 2\x11 \x07 \xec " ) ;
180- assert_eq ! ( ec_vec. as_slice ( ) ,
180+ assert_eq ! ( ec_vec[ ] ,
181181 b"\xd5 W\x94 \xeb \xc7 \xcc t\x9f \x0b `\xb1 \x05 -<\xd4 \xad s\xca L\x18 \xf7 \xb6 \x85 \x93 \xf1 |K;\xdf \x9d \xf2 !\xe5 \xc8 \xee j\xf8 \x86 L(\x9a \x1b \xc3 \xff u\x81 \xe6 \xac \x9a \xd1 \xbd Ro\x11 \n \x02 V\xa3 l\x83 \xa1 \xa3 \xf0 ox\xc0 \xb2 '\x85 \x8d \xec " ) ;
182182 }
183183}
0 commit comments