Address edition-2018 idioms. (#929)

This commit is contained in:
Roman Borschel
2019-02-11 14:58:15 +01:00
committed by Pierre Krieger
parent 21810e46bd
commit eeed66707b
75 changed files with 308 additions and 516 deletions

View File

@ -9,7 +9,7 @@ pub enum EncodeError {
impl fmt::Display for EncodeError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
EncodeError::UnsupportedType => write!(f, "This type is not supported yet"),
}
@ -29,7 +29,7 @@ pub enum DecodeError {
impl fmt::Display for DecodeError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
DecodeError::BadInputLength => write!(f, "Not matching input length"),
DecodeError::UnknownCode => write!(f, "Found unknown code"),
@ -52,7 +52,7 @@ pub struct DecodeOwnedError {
impl fmt::Display for DecodeOwnedError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.error)
}
}

View File

@ -5,19 +5,11 @@
//! A `Multihash` is a structure that contains a hashing algorithm, plus some hashed data.
//! A `MultihashRef` is the same as a `Multihash`, except that it doesn't own its data.
extern crate blake2;
extern crate rand;
extern crate sha1;
extern crate sha2;
extern crate tiny_keccak;
extern crate unsigned_varint;
mod errors;
mod hashes;
use std::fmt::Write;
use sha2::Digest;
use std::fmt::Write;
use tiny_keccak::Keccak;
use unsigned_varint::{decode, encode};
@ -169,7 +161,7 @@ impl Multihash {
/// Builds a `MultihashRef` corresponding to this `Multihash`.
#[inline]
pub fn as_ref(&self) -> MultihashRef {
pub fn as_ref(&self) -> MultihashRef<'_> {
MultihashRef { bytes: &self.bytes }
}