@@ -3,6 +3,12 @@ use crate::hasher::{Digest, Size, StatefulHasher};
3
3
use core:: convert:: TryFrom ;
4
4
use generic_array:: GenericArray ;
5
5
6
+ #[ cfg( feature = "std" ) ]
7
+ use std:: io;
8
+
9
+ #[ cfg( not( feature = "std" ) ) ]
10
+ use core2:: io;
11
+
6
12
macro_rules! derive_digest {
7
13
( $name: ident) => {
8
14
/// Multihash digest.
@@ -52,14 +58,13 @@ macro_rules! derive_digest {
52
58
53
59
macro_rules! derive_write {
54
60
( $name: ident) => {
55
- #[ cfg( feature = "std" ) ]
56
- impl <S : Size > std:: io:: Write for $name<S > {
57
- fn write( & mut self , buf: & [ u8 ] ) -> std:: io:: Result <usize > {
61
+ impl <S : Size > io:: Write for $name<S > {
62
+ fn write( & mut self , buf: & [ u8 ] ) -> io:: Result <usize > {
58
63
self . update( buf) ;
59
64
Ok ( buf. len( ) )
60
65
}
61
66
62
- fn flush( & mut self ) -> std :: io:: Result <( ) > {
67
+ fn flush( & mut self ) -> io:: Result <( ) > {
63
68
Ok ( ( ) )
64
69
}
65
70
}
@@ -222,14 +227,13 @@ macro_rules! derive_hasher_sha {
222
227
}
223
228
}
224
229
225
- #[ cfg( feature = "std" ) ]
226
- impl std:: io:: Write for $name {
227
- fn write( & mut self , buf: & [ u8 ] ) -> std:: io:: Result <usize > {
230
+ impl io:: Write for $name {
231
+ fn write( & mut self , buf: & [ u8 ] ) -> io:: Result <usize > {
228
232
self . update( buf) ;
229
233
Ok ( buf. len( ) )
230
234
}
231
235
232
- fn flush( & mut self ) -> std :: io:: Result <( ) > {
236
+ fn flush( & mut self ) -> io:: Result <( ) > {
233
237
Ok ( ( ) )
234
238
}
235
239
}
@@ -325,10 +329,9 @@ pub mod identity {
325
329
326
330
// A custom implementation is needed as an identity hash also stores the actual size of
327
331
// the given digest.
328
- #[ cfg( feature = "std" ) ]
329
332
fn from_reader < R > ( mut r : R ) -> Result < Self , Error >
330
333
where
331
- R : std :: io:: Read ,
334
+ R : io:: Read ,
332
335
{
333
336
use crate :: multihash:: read_u64;
334
337
0 commit comments