Skip to content

Commit b22c7e6

Browse files
committed
fix clippy
1 parent 2ee67c1 commit b22c7e6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/test_utils.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use async_h1::{
55
use async_std::io::{Read, Write};
66
use http_types::{Request, Response, Result};
77
use std::{
8-
fmt::Debug,
8+
fmt::{Debug, Display},
99
future::Future,
1010
io,
1111
pin::Pin,
@@ -122,17 +122,19 @@ impl CloseableCursor {
122122
self.len() == self.cursor()
123123
}
124124

125-
pub fn to_string(&self) -> String {
126-
std::str::from_utf8(&*self.data.read().unwrap())
127-
.unwrap_or("not utf8")
128-
.to_owned()
129-
}
130-
131125
fn close(&self) {
132126
*self.closed.write().unwrap() = true;
133127
}
134128
}
135129

130+
impl Display for CloseableCursor {
131+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
132+
let data = &*self.data.read().unwrap();
133+
let s = std::str::from_utf8(data).unwrap_or("not utf8");
134+
write!(f, "{}", s)
135+
}
136+
}
137+
136138
impl TestIO {
137139
pub fn new() -> (TestIO, TestIO) {
138140
let client = Arc::new(CloseableCursor::default());

0 commit comments

Comments
 (0)