Skip to content

Commit b21e02d

Browse files
committed
clippy --fix
1 parent 39c7dae commit b21e02d

File tree

10 files changed

+21
-27
lines changed

10 files changed

+21
-27
lines changed

benches/throughput.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const CLIENTS: usize = 1;
2121

2222
fn bench_throughput(c: &mut Criterion) {
2323
test_utils::log();
24-
let address = format!("localhost:{}", PORT);
24+
let address = format!("localhost:{PORT}");
2525

2626
let mut group = c.benchmark_group("throughput");
2727
let data = vec![1u8; SIZE as usize];

src/channels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,5 +512,5 @@ impl ChannelMap {
512512
}
513513

514514
fn error(message: &str) -> Error {
515-
Error::new(ErrorKind::Other, message)
515+
Error::other(message)
516516
}

src/crypto/cipher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl DecryptCipher {
6767
pub(crate) fn decrypt_buf(&mut self, buf: &[u8]) -> io::Result<(Vec<u8>, Tag)> {
6868
let mut to_decrypt = buf.to_vec();
6969
let tag = &self.pull_stream.pull(&mut to_decrypt, &[]).map_err(|err| {
70-
io::Error::new(io::ErrorKind::Other, format!("Decrypt failed: {err}"))
70+
io::Error::other(format!("Decrypt failed: {err}"))
7171
})?;
7272
Ok((to_decrypt, *tag))
7373
}
@@ -147,7 +147,7 @@ impl EncryptCipher {
147147
self.push_stream
148148
.push(&mut out, &[], Tag::Message)
149149
.map_err(|err| {
150-
io::Error::new(io::ErrorKind::Other, format!("Encrypt failed: {err}"))
150+
io::Error::other(format!("Encrypt failed: {err}"))
151151
})?;
152152
Ok(out)
153153
}

src/crypto/handshake.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl Handshake {
183183
pub fn read_raw(&mut self, msg: &[u8]) -> Result<Option<Vec<u8>>> {
184184
// eprintln!("hs read len {}", msg.len());
185185
if self.complete() {
186-
return Err(Error::new(ErrorKind::Other, "Handshake read after finish"));
186+
return Err(Error::other("Handshake read after finish"));
187187
}
188188

189189
let rx_len = self.recv(msg)?;
@@ -231,7 +231,7 @@ impl Handshake {
231231
/// get the handshake result when it is completed
232232
pub fn get_result(&self) -> Result<&HandshakeResult> {
233233
if !self.complete() {
234-
Err(Error::new(ErrorKind::Other, "Handshake is not complete"))
234+
Err(Error::other("Handshake is not complete"))
235235
} else {
236236
Ok(&self.result)
237237
}

src/noise.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl std::fmt::Display for Step {
4545
Step::SecretStream(_) => "SecretStream",
4646
Step::Established(_) => "Established",
4747
};
48-
write!(f, "{}", x)
48+
write!(f, "{x}")
4949
}
5050
}
5151

src/sstream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl IkSecretStream<ResponderInitial> {
136136
pub fn new_responder(private: &[u8]) -> Result<Self, Error> {
137137
let params: NoiseParams = PARAMS.parse().expect("known to work");
138138
let state = Builder::new(params.clone())
139-
.local_private_key(&private)?
139+
.local_private_key(private)?
140140
.build_responder()?;
141141
Ok(Self {
142142
is_initiator: false,

src/test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(dead_code)]
22
use std::{
3-
io::{self, ErrorKind},
3+
io::{self},
44
pin::Pin,
55
task::{Context, Poll},
66
};
@@ -41,7 +41,7 @@ impl Sink<Vec<u8>> for Io {
4141
fn start_send(mut self: Pin<&mut Self>, item: Vec<u8>) -> Result<(), Self::Error> {
4242
Pin::new(&mut self.sender)
4343
.start_send(item)
44-
.map_err(|_e| io::Error::new(ErrorKind::Other, "SendError"))
44+
.map_err(|_e| io::Error::other("SendError"))
4545
}
4646

4747
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
@@ -125,7 +125,7 @@ impl<Rx: Unpin, TxItem: Unpin, TxChannel: Sink<TxItem> + Unpin> Sink<TxItem>
125125
let this = self.get_mut();
126126
Pin::new(&mut this.sender)
127127
.start_send(item)
128-
.map_err(|_e| io::Error::new(ErrorKind::Other, "SendError"))
128+
.map_err(|_e| io::Error::other("SendError"))
129129
}
130130

131131
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {

tests/_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub async fn wait_for_localhost_port(port: u32) {
9393
loop {
9494
let timeout = async_std::future::timeout(
9595
Duration::from_millis(NO_RESPONSE_TIMEOUT),
96-
TcpStream::connect(format!("localhost:{}", port)),
96+
TcpStream::connect(format!("localhost:{port}")),
9797
)
9898
.await;
9999
if timeout.is_err() {

tests/js/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ pub fn install() {
4343
}
4444

4545
pub fn prepare_test_set(test_set: &str) -> (String, String, String) {
46-
let path_result = format!("tests/js/work/{}/result.txt", test_set);
47-
let path_writer = format!("tests/js/work/{}/writer", test_set);
48-
let path_reader = format!("tests/js/work/{}/reader", test_set);
46+
let path_result = format!("tests/js/work/{test_set}/result.txt");
47+
let path_writer = format!("tests/js/work/{test_set}/writer");
48+
let path_reader = format!("tests/js/work/{test_set}/reader");
4949
create_dir_all(&path_writer).expect("Unable to create work writer directory");
5050
create_dir_all(&path_reader).expect("Unable to create work reader directory");
5151
(path_result, path_writer, path_reader)
@@ -100,13 +100,7 @@ impl JavascriptServer {
100100
assert_eq!(
101101
Some(0),
102102
code,
103-
"node server did not exit successfully, is_writer={}, port={}, data_count={}, data_size={}, data_char={}, test_set={}",
104-
is_writer,
105-
port,
106-
data_count,
107-
data_size,
108-
data_char,
109-
test_set,
103+
"node server did not exit successfully, is_writer={is_writer}, port={port}, data_count={data_count}, data_size={data_size}, data_char={data_char}, test_set={test_set}",
110104
);
111105
}));
112106
wait_for_localhost_port(port).await;

tests/js_interop.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ async fn assert_result(
314314
let expected_value = data_char.to_string().repeat(item_size);
315315
let mut line = String::new();
316316
while reader.read_line(&mut line).await? != 0 {
317-
assert_eq!(line, format!("{} {}\n", i, expected_value));
317+
assert_eq!(line, format!("{i} {expected_value}\n"));
318318
i += 1;
319319
line = String::new();
320320
}
@@ -737,7 +737,7 @@ async fn on_replication_message(
737737
let mut writer = BufWriter::new(File::create(result_path).await?);
738738
for i in 0..new_info.contiguous_length {
739739
let value = String::from_utf8(hypercore.get(i).await?.unwrap()).unwrap();
740-
let line = format!("{} {}\n", i, value);
740+
let line = format!("{i} {value}\n");
741741
let n_written = writer.write(line.as_bytes()).await?;
742742
if line.len() != n_written {
743743
panic!("Couldn't write all write all bytse");
@@ -770,7 +770,7 @@ async fn on_replication_message(
770770
}
771771
}
772772
_ => {
773-
panic!("Received unexpected message {:?}", message);
773+
panic!("Received unexpected message {message:?}");
774774
}
775775
};
776776
Ok(false)
@@ -831,7 +831,7 @@ where
831831
F: Future<Output = Result<()>> + Send,
832832
C: Clone + Send + 'static,
833833
{
834-
let listener = TcpListener::bind(&format!("localhost:{}", port)).await?;
834+
let listener = TcpListener::bind(&format!("localhost:{port}")).await?;
835835

836836
while let Ok((stream, _peer_address)) = listener.accept().await {
837837
let context = context.clone();
@@ -853,6 +853,6 @@ where
853853
F: Future<Output = Result<()>> + Send,
854854
C: Clone + Send + 'static,
855855
{
856-
let stream = TcpStream::connect(&format!("localhost:{}", port)).await?;
856+
let stream = TcpStream::connect(&format!("localhost:{port}")).await?;
857857
onconnection(stream, true, context).await
858858
}

0 commit comments

Comments
 (0)