@@ -125,15 +125,12 @@ pub async fn test_write_to_file(
125125
126126 for k in 0 ..src_buf. len ( ) {
127127 if src_buf[ k] != dst_buf[ k] {
128- return Err ( std:: io:: Error :: new (
129- std:: io:: ErrorKind :: Other ,
130- format ! (
131- "Data validation failed at {}: written {:?}, read {:?}" ,
132- pos + k as u64 ,
133- src_buf[ k] ,
134- dst_buf[ k]
135- ) ,
136- ) ) ;
128+ return Err ( std:: io:: Error :: other ( format ! (
129+ "Data validation failed at {}: written {:?}, read {:?}" ,
130+ pos + k as u64 ,
131+ src_buf[ k] ,
132+ dst_buf[ k]
133+ ) ) ) ;
137134 }
138135 }
139136
@@ -170,7 +167,7 @@ pub async fn compare_files(
170167 path_a : impl AsRef < Path > ,
171168 path_b : impl AsRef < Path > ,
172169) -> std:: io:: Result < ( ) > {
173- use std:: io:: { Error , ErrorKind } ;
170+ use std:: io:: Error ;
174171
175172 let name_a = path_a. as_ref ( ) ;
176173 let name_b = path_b. as_ref ( ) ;
@@ -201,10 +198,9 @@ pub async fn compare_files(
201198 let nb = fb. read ( & mut buf_b) . await ?;
202199
203200 if na != nb {
204- return Err ( Error :: new (
205- ErrorKind :: Other ,
206- format ! ( "Size of file {name_a:?} != size of {name_b:?}" ) ,
207- ) ) ;
201+ return Err ( Error :: other ( format ! (
202+ "Size of file {name_a:?} != size of {name_b:?}"
203+ ) ) ) ;
208204 }
209205
210206 if na == 0 {
@@ -213,16 +209,13 @@ pub async fn compare_files(
213209
214210 for i in 0 ..na {
215211 if buf_a[ i] != buf_b[ i] {
216- return Err ( Error :: new (
217- ErrorKind :: Other ,
218- format ! (
219- "Miscompare at {pos}: {na:?} {va:#02x} != {nb:?} {vb:#02x}" ,
220- na = name_a,
221- va = buf_a[ i] ,
222- nb = name_b,
223- vb = buf_b[ i] ,
224- ) ,
225- ) ) ;
212+ return Err ( Error :: other ( format ! (
213+ "Miscompare at {pos}: {na:?} {va:#02x} != {nb:?} {vb:#02x}" ,
214+ na = name_a,
215+ va = buf_a[ i] ,
216+ nb = name_b,
217+ vb = buf_b[ i] ,
218+ ) ) ) ;
226219 }
227220 pos += 1 ;
228221 }
0 commit comments