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

@ -76,7 +76,7 @@ pub enum SecioError {
}
impl error::Error for SecioError {
fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
SecioError::IoError(ref err) => Some(err),
SecioError::Protobuf(ref err) => Some(err),
@ -91,7 +91,7 @@ impl error::Error for SecioError {
impl fmt::Display for SecioError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
SecioError::IoError(e) =>
write!(f, "I/O error: {}", e),

View File

@ -221,7 +221,7 @@ impl SecioKeyPair {
pub fn rsa_from_pkcs8<P>(
private: &[u8],
public: P,
) -> Result<SecioKeyPair, Box<Error + Send + Sync>>
) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>>
where
P: Into<Vec<u8>>,
{
@ -236,7 +236,7 @@ impl SecioKeyPair {
}
/// Generates a new Ed25519 key pair and uses it.
pub fn ed25519_generated() -> Result<SecioKeyPair, Box<Error + Send + Sync>> {
pub fn ed25519_generated() -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> {
let mut csprng = rand::thread_rng();
let keypair: Ed25519KeyPair = Ed25519KeyPair::generate::<_>(&mut csprng);
Ok(SecioKeyPair {
@ -249,7 +249,7 @@ impl SecioKeyPair {
/// Builds a `SecioKeyPair` from a raw ed25519 32 bytes private key.
///
/// Returns an error if the slice doesn't have the correct length.
pub fn ed25519_raw_key(key: impl AsRef<[u8]>) -> Result<SecioKeyPair, Box<Error + Send + Sync>> {
pub fn ed25519_raw_key(key: impl AsRef<[u8]>) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> {
let secret = ed25519_dalek::SecretKey::from_bytes(key.as_ref())
.map_err(|err| err.to_string())?;
let public = ed25519_dalek::PublicKey::from(&secret);
@ -266,7 +266,7 @@ impl SecioKeyPair {
/// Generates a new random sec256k1 key pair.
#[cfg(feature = "secp256k1")]
pub fn secp256k1_generated() -> Result<SecioKeyPair, Box<Error + Send + Sync>> {
pub fn secp256k1_generated() -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>> {
let private = secp256k1::key::SecretKey::new(&mut secp256k1::rand::thread_rng());
Ok(SecioKeyPair {
inner: SecioKeyPairInner::Secp256k1 { private },
@ -275,7 +275,7 @@ impl SecioKeyPair {
/// Builds a `SecioKeyPair` from a raw secp256k1 32 bytes private key.
#[cfg(feature = "secp256k1")]
pub fn secp256k1_raw_key<K>(key: K) -> Result<SecioKeyPair, Box<Error + Send + Sync>>
pub fn secp256k1_raw_key<K>(key: K) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>>
where
K: AsRef<[u8]>,
{
@ -288,7 +288,7 @@ impl SecioKeyPair {
/// Builds a `SecioKeyPair` from a secp256k1 private key in DER format.
#[cfg(feature = "secp256k1")]
pub fn secp256k1_from_der<K>(key: K) -> Result<SecioKeyPair, Box<Error + Send + Sync>>
pub fn secp256k1_from_der<K>(key: K) -> Result<SecioKeyPair, Box<dyn Error + Send + Sync>>
where
K: AsRef<[u8]>,
{

View File

@ -225,7 +225,7 @@ impl ::protobuf::Message for Propose {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> {
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
@ -276,7 +276,7 @@ impl ::protobuf::Message for Propose {
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> {
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if let Some(ref v) = self.rand.as_ref() {
os.write_bytes(1, &v)?;
}
@ -308,13 +308,13 @@ impl ::protobuf::Message for Propose {
&mut self.unknown_fields
}
fn as_any(&self) -> &::std::any::Any {
self as &::std::any::Any
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut ::std::any::Any {
self as &mut ::std::any::Any
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
fn into_any(self: Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
@ -391,13 +391,13 @@ impl ::protobuf::Clear for Propose {
}
impl ::std::fmt::Debug for Propose {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for Propose {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> {
::protobuf::reflect::ProtobufValueRef::Message(self)
}
}
@ -495,7 +495,7 @@ impl ::protobuf::Message for Exchange {
true
}
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> {
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
@ -528,7 +528,7 @@ impl ::protobuf::Message for Exchange {
my_size
}
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> {
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if let Some(ref v) = self.epubkey.as_ref() {
os.write_bytes(1, &v)?;
}
@ -551,13 +551,13 @@ impl ::protobuf::Message for Exchange {
&mut self.unknown_fields
}
fn as_any(&self) -> &::std::any::Any {
self as &::std::any::Any
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut ::std::any::Any {
self as &mut ::std::any::Any
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
fn into_any(self: Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
self
}
@ -616,13 +616,13 @@ impl ::protobuf::Clear for Exchange {
}
impl ::std::fmt::Debug for Exchange {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
impl ::protobuf::reflect::ProtobufValue for Exchange {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef {
fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> {
::protobuf::reflect::ProtobufValueRef::Message(self)
}
}