Skip to content

Commit caac5a6

Browse files
committed
clippy fixes
1 parent e11a46c commit caac5a6

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

contract-tests/src/bin/sse-test-api/stream_entity.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl Inner {
4747
Ok(None) => break,
4848
Err(e) => {
4949
let failure = EventType::Error {
50-
error: format!("Error: {:?}", e),
50+
error: format!("Error: {e:?}"),
5151
};
5252

5353
if !self.send_message(failure, &client).await {
@@ -62,7 +62,7 @@ impl Inner {
6262
let json = match serde_json::to_string(&event_type) {
6363
Ok(s) => s,
6464
Err(e) => {
65-
error!("Failed to json encode event type {:?}", e);
65+
error!("Failed to json encode event type {e:?}");
6666
return false;
6767
}
6868
};
@@ -73,7 +73,7 @@ impl Inner {
7373

7474
match client
7575
.post(format!("{}/{}", self.callback_url, counter_val))
76-
.body(format!("{}\n", json))
76+
.body(format!("{json}\n"))
7777
.send()
7878
.await
7979
{
@@ -82,7 +82,7 @@ impl Inner {
8282
*counter = counter_val + 1
8383
}
8484
Err(e) => {
85-
error!("Failed to send post back to test harness {:?}", e);
85+
error!("Failed to send post back to test harness {e:?}");
8686
return false;
8787
}
8888
};
@@ -93,7 +93,7 @@ impl Inner {
9393
fn build_client(config: &Config) -> Result<Box<dyn es::Client>, String> {
9494
let mut client_builder = match es::ClientBuilder::for_url(&config.stream_url) {
9595
Ok(cb) => cb,
96-
Err(e) => return Err(format!("Failed to create client builder {:?}", e)),
96+
Err(e) => return Err(format!("Failed to create client builder {e:?}")),
9797
};
9898

9999
let mut reconnect_options = es::ReconnectOptions::reconnect(true);
@@ -122,7 +122,7 @@ impl Inner {
122122
for (name, value) in headers {
123123
client_builder = match client_builder.header(name, value) {
124124
Ok(cb) => cb,
125-
Err(e) => return Err(format!("Unable to set header {:?}", e)),
125+
Err(e) => return Err(format!("Unable to set header {e:?}")),
126126
};
127127
}
128128
}

eventsource-client/examples/tail.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ fn tail_events(client: impl es::Client) -> impl Stream<Item = Result<(), ()>> {
4747
println!("got an event: {}\n{}", ev.event_type, ev.data)
4848
}
4949
es::SSE::Comment(comment) => {
50-
println!("got a comment: \n{}", comment)
50+
println!("got a comment: \n{comment}")
5151
}
5252
})
53-
.map_err(|err| eprintln!("error streaming events: {:?}", err))
53+
.map_err(|err| eprintln!("error streaming events: {err:?}"))
5454
}

eventsource-client/src/client.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ impl ClientBuilder {
141141

142142
/// Set the Authorization header with the calculated basic authentication value.
143143
pub fn basic_auth(self, username: &str, password: &str) -> Result<ClientBuilder> {
144-
let auth = format!("{}:{}", username, password);
144+
let auth = format!("{username}:{password}");
145145
let encoded = BASE64_STANDARD.encode(auth);
146-
let value = format!("Basic {}", encoded);
146+
let value = format!("Basic {encoded}");
147147

148148
self.header("Authorization", &value)
149149
}
@@ -477,7 +477,7 @@ where
477477
}
478478
StateProj::Connecting { retry, resp } => match ready!(resp.poll(cx)) {
479479
Ok(resp) => {
480-
debug!("HTTP response: {:#?}", resp);
480+
debug!("HTTP response: {resp:#?}");
481481

482482
if resp.status().is_success() {
483483
self.as_mut().project().retry_strategy.reset(Instant::now());
@@ -544,7 +544,7 @@ where
544544
}
545545
Err(e) => {
546546
// This happens when the server is unreachable, e.g. connection refused.
547-
warn!("request returned an error: {}", e);
547+
warn!("request returned an error: {e}");
548548
if !*retry {
549549
self.as_mut().project().state.set(State::StreamClosed);
550550
return Poll::Ready(Some(Err(Error::HttpStream(Box::new(e)))));
@@ -645,7 +645,7 @@ fn uri_from_header(maybe_header: &Option<HeaderValue>) -> Result<Uri> {
645645
}
646646

647647
fn delay(dur: Duration, description: &str) -> Sleep {
648-
info!("Waiting {:?} before {}", dur, description);
648+
info!("Waiting {dur:?} before {description}");
649649
tokio::time::sleep(dur)
650650
}
651651

@@ -679,7 +679,7 @@ mod tests {
679679
.expect("failed to add authentication");
680680

681681
let actual = builder.headers.get("Authorization");
682-
let expected = HeaderValue::from_str(format!("Basic {}", expected).as_str())
682+
let expected = HeaderValue::from_str(format!("Basic {expected}").as_str())
683683
.expect("unable to create expected header");
684684

685685
assert_eq!(Some(&expected), actual);
@@ -697,7 +697,7 @@ mod tests {
697697
ReconnectOptionsBuilder, ReconnectingRequest,
698698
};
699699

700-
const INVALID_URI: &'static str = "http://mycrazyunexsistenturl.invaliddomainext";
700+
const INVALID_URI: &str = "http://mycrazyunexsistenturl.invaliddomainext";
701701

702702
#[test_case(INVALID_URI, false, |state| matches!(state, State::StreamClosed))]
703703
#[test_case(INVALID_URI, true, |state| matches!(state, State::WaitingToReconnect(_)))]

eventsource-client/src/event_parser.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl EventParser {
186186
}
187187

188188
pub fn process_bytes(&mut self, bytes: Bytes) -> Result<()> {
189-
trace!("Parsing bytes {:?}", bytes);
189+
trace!("Parsing bytes {bytes:?}");
190190
// We get bytes from the underlying stream in chunks. Decoding a chunk has two phases:
191191
// decode the chunk into lines, and decode the lines into events.
192192
//
@@ -255,7 +255,7 @@ impl EventParser {
255255
Ok(retry) => {
256256
event_data.retry = Some(retry);
257257
}
258-
_ => debug!("Failed to parse {:?} into retry value", value),
258+
_ => debug!("Failed to parse {value:?} into retry value"),
259259
};
260260
}
261261
}
@@ -424,7 +424,7 @@ mod tests {
424424

425425
match parse_field(b"\x80: invalid UTF-8") {
426426
Err(InvalidLine(msg)) => assert!(msg.contains("Utf8Error")),
427-
res => panic!("expected InvalidLine error, got {:?}", res),
427+
res => panic!("expected InvalidLine error, got {res:?}"),
428428
}
429429
}
430430

@@ -719,8 +719,8 @@ mod tests {
719719
}
720720

721721
fn read_contents_from_file(name: &str) -> Vec<u8> {
722-
std::fs::read(format!("test-data/{}", name))
723-
.unwrap_or_else(|_| panic!("couldn't read {}", name))
722+
std::fs::read(format!("test-data/{name}"))
723+
.unwrap_or_else(|_| panic!("couldn't read {name}"))
724724
}
725725

726726
proptest! {

0 commit comments

Comments
 (0)