Skip to content

Commit 93454ea

Browse files
committed
Formatting
1 parent 5275973 commit 93454ea

File tree

4 files changed

+37
-41
lines changed

4 files changed

+37
-41
lines changed

src/error.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#[cfg(feature = "std")]
2-
use std::io::Error as IoError;
31
#[cfg(not(feature = "std"))]
42
use core2::io::Error as IoError;
5-
3+
#[cfg(feature = "std")]
4+
use std::io::Error as IoError;
5+
66
use unsigned_varint::decode::Error as DecodeError;
77
#[cfg(feature = "std")]
88
use unsigned_varint::io::ReadError;
@@ -36,14 +36,14 @@ impl core::fmt::Display for Error {
3636
impl std::error::Error for Error {}
3737

3838
#[cfg(not(feature = "std"))]
39-
impl core2::error::Error for Error {}
39+
impl core2::error::Error for Error {}
4040

4141
#[cfg(not(feature = "std"))]
4242
impl From<core2::io::Error> for Error {
43-
fn from(err: core2::io::Error) -> Self {
44-
Self::Io(err)
45-
}
46-
}
43+
fn from(err: core2::io::Error) -> Self {
44+
Self::Io(err)
45+
}
46+
}
4747

4848
#[cfg(feature = "std")]
4949
impl From<IoError> for Error {

src/hasher.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ pub trait Digest<S: Size>:
5858
where
5959
R: io::Read,
6060
{
61-
#[cfg(not(feature = "std"))]
62-
use crate::varint_read_u64 as read_u64;
63-
64-
#[cfg(feature = "std")]
65-
use unsigned_varint::io::read_u64;
61+
#[cfg(not(feature = "std"))]
62+
use crate::varint_read_u64 as read_u64;
63+
64+
#[cfg(feature = "std")]
65+
use unsigned_varint::io::read_u64;
6666

6767
let size = read_u64(&mut r)?;
6868
if size > S::to_u64() || size > u8::max_value() as u64 {

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,3 @@ pub use crate::hasher_impl::sha3::{Sha3Digest, Sha3_224, Sha3_256, Sha3_384, Sha
9393
#[cfg(feature = "strobe")]
9494
pub use crate::hasher_impl::strobe::{Strobe256, Strobe512, StrobeDigest, StrobeHasher};
9595
pub use crate::hasher_impl::unknown::UnknownDigest;
96-

src/multihash.rs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use core::convert::TryInto;
88
use core::fmt::Debug;
99
use generic_array::{ArrayLength, GenericArray};
1010

11-
use unsigned_varint::{encode as varint_encode, decode};
11+
use unsigned_varint::{decode, encode as varint_encode};
1212

1313
#[cfg(feature = "std")]
1414
use std::io;
@@ -261,7 +261,6 @@ pub fn write_multihash<W>(mut w: W, code: u64, size: u8, digest: &[u8]) -> Resul
261261
where
262262
W: io::Write,
263263
{
264-
265264
let mut code_buf = varint_encode::u64_buffer();
266265
let code = varint_encode::u64(code, &mut code_buf);
267266

@@ -285,20 +284,20 @@ where
285284
R: io::Read,
286285
S: Size,
287286
{
288-
#[cfg(not(feature = "std"))]
289-
use crate::read_u64 as read_u64;
290-
291-
#[cfg(feature = "std")]
292-
use unsigned_varint::io::read_u64;
293-
294-
let code = match read_u64(&mut r) {
295-
Ok(c) => c,
296-
Err(e) => return Err(e.into()),
297-
};
298-
let size = match read_u64(&mut r) {
299-
Ok(s) => s,
300-
Err(e) => return Err(e.into()),
301-
};
287+
#[cfg(not(feature = "std"))]
288+
use crate::read_u64;
289+
290+
#[cfg(feature = "std")]
291+
use unsigned_varint::io::read_u64;
292+
293+
let code = match read_u64(&mut r) {
294+
Ok(c) => c,
295+
Err(e) => return Err(e.into()),
296+
};
297+
let size = match read_u64(&mut r) {
298+
Ok(s) => s,
299+
Err(e) => return Err(e.into()),
300+
};
302301

303302
if size > S::to_u64() || size > u8::MAX as u64 {
304303
return Err(Error::InvalidSize(size));
@@ -313,20 +312,18 @@ where
313312
/// Adapted from unsigned-varint's generated read_u64 function at
314313
/// https://github.com/paritytech/unsigned-varint/blob/master/src/io.rs
315314
pub fn read_u64<R: io::Read>(mut r: R) -> Result<u64, Error> {
316-
let mut b = varint_encode::u64_buffer();
317-
for i in 0..b.len() {
318-
let n = r.read(&mut (b[i..i + 1]))?;
319-
if n == 0 {
320-
return Err(Error::Varint(decode::Error::Insufficient));
321-
}
322-
else if decode::is_last(b[i]) {
323-
return Ok(decode::u64(&b[..=i]).unwrap().0);
315+
let mut b = varint_encode::u64_buffer();
316+
for i in 0..b.len() {
317+
let n = r.read(&mut (b[i..i + 1]))?;
318+
if n == 0 {
319+
return Err(Error::Varint(decode::Error::Insufficient));
320+
} else if decode::is_last(b[i]) {
321+
return Ok(decode::u64(&b[..=i]).unwrap().0);
322+
}
324323
}
325-
}
326-
Err(Error::Varint(decode::Error::Overflow))
324+
Err(Error::Varint(decode::Error::Overflow))
327325
}
328326

329-
330327
#[cfg(test)]
331328
mod tests {
332329
use super::*;

0 commit comments

Comments
 (0)