Skip to content

Commit c459b60

Browse files
committed
Fix compiler and clippy warnings
1 parent fbf608b commit c459b60

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

derive/src/function.rs

+3
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ mod tests {
222222

223223
#[test]
224224
fn test_no_params() {
225+
#[allow(deprecated)]
225226
let ethabi_function = ethabi::Function {
226227
name: "empty".into(),
227228
inputs: vec![],
@@ -285,6 +286,7 @@ mod tests {
285286

286287
#[test]
287288
fn test_one_param() {
289+
#[allow(deprecated)]
288290
let ethabi_function = ethabi::Function {
289291
name: "hello".into(),
290292
inputs: vec![ethabi::Param { name: "foo".into(), kind: ethabi::ParamType::Address }],
@@ -354,6 +356,7 @@ mod tests {
354356

355357
#[test]
356358
fn test_multiple_params() {
359+
#[allow(deprecated)]
357360
let ethabi_function = ethabi::Function {
358361
name: "multi".into(),
359362
inputs: vec![

ethabi/src/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn decode(types: &[ParamType], data: &[u8]) -> Result<Vec<Token>, Error> {
6464

6565
fn peek(data: &[u8], offset: usize, len: usize) -> Result<&[u8], Error> {
6666
if offset + len > data.len() {
67-
return Err(Error::InvalidData);
67+
Err(Error::InvalidData)
6868
} else {
6969
Ok(&data[offset..(offset + len)])
7070
}
@@ -80,7 +80,7 @@ fn peek_32_bytes(data: &[u8], offset: usize) -> Result<Word, Error> {
8080

8181
fn take_bytes(data: &[u8], offset: usize, len: usize) -> Result<Vec<u8>, Error> {
8282
if offset + len > data.len() {
83-
return Err(Error::InvalidData);
83+
Err(Error::InvalidData)
8484
} else {
8585
Ok((&data[offset..(offset + len)]).to_vec())
8686
}

ethabi/src/filter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ impl<T> From<Vec<T>> for Topic<T> {
104104
}
105105
}
106106

107-
impl<T> Into<Vec<T>> for Topic<T> {
108-
fn into(self) -> Vec<T> {
109-
match self {
107+
impl<T> From<Topic<T>> for Vec<T> {
108+
fn from(topic: Topic<T>) -> Self {
109+
match topic {
110110
Topic::Any => vec![],
111111
Topic::This(topic) => vec![topic],
112112
Topic::OneOf(topics) => topics,

ethabi/src/function.rs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ mod tests {
9595

9696
#[test]
9797
fn test_function_encode_call() {
98+
#[allow(deprecated)]
9899
let func = Function {
99100
name: "baz".to_owned(),
100101
inputs: vec![

ethabi/src/operation.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ impl<'a> Deserialize<'a> for Operation {
6565
mod tests {
6666
use super::Operation;
6767
use crate::{Event, EventParam, Function, Param, ParamType, StateMutability};
68-
use serde_json;
6968

7069
#[test]
7170
fn deserialize_operation() {
@@ -81,16 +80,15 @@ mod tests {
8180

8281
let deserialized: Operation = serde_json::from_str(s).unwrap();
8382

84-
assert_eq!(
85-
deserialized,
86-
Operation::Function(Function {
87-
name: "foo".to_owned(),
88-
inputs: vec![Param { name: "a".to_owned(), kind: ParamType::Address }],
89-
outputs: vec![],
90-
constant: false,
91-
state_mutability: StateMutability::NonPayable,
92-
})
93-
);
83+
#[allow(deprecated)]
84+
let function = Function {
85+
name: "foo".to_owned(),
86+
inputs: vec![Param { name: "a".to_owned(), kind: ParamType::Address }],
87+
outputs: vec![],
88+
constant: false,
89+
state_mutability: StateMutability::NonPayable,
90+
};
91+
assert_eq!(deserialized, Operation::Function(function));
9492
}
9593

9694
#[test]

tests/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ mod tests {
2121

2222
struct Wrapper([u8; 20]);
2323

24-
impl Into<Address> for Wrapper {
25-
fn into(self) -> Address {
26-
self.0.into()
24+
impl From<Wrapper> for Address {
25+
fn from(wrapper: Wrapper) -> Self {
26+
wrapper.0.into()
2727
}
2828
}
2929

0 commit comments

Comments
 (0)