Skip to content

Commit 5d8fe95

Browse files
authored
general: apply clippy lints (webrtc-rs#407)
* general: update crates to 2021 edition. * general: apply clippy --fix * general: apply manual clippy lints * cargo fmt.
1 parent 95f8c26 commit 5d8fe95

File tree

280 files changed

+894
-1365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+894
-1365
lines changed

constraints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "webrtc-constraints"
33
version = "0.1.0"
44
authors = ["Vincent Esche <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66
description = "A pure Rust implementation of WebRTC Media Constraints API"
77
license = "MIT/Apache-2.0"
88
documentation = "https://docs.rs/webrtc-constraints"

constraints/src/algorithms/fitness_distance/setting.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ mod tests {
345345

346346
let expected = 0.0;
347347

348-
println!("constraint: {:?}", constraint);
349-
println!("setting: {:?}", setting);
350-
println!("actual: {:?}", actual);
351-
println!("expected: {:?}", expected);
348+
println!("constraint: {constraint:?}");
349+
println!("setting: {setting:?}");
350+
println!("actual: {actual:?}");
351+
println!("expected: {expected:?}");
352352

353353
assert_eq!(actual, expected);
354354
}
@@ -434,10 +434,10 @@ mod tests {
434434

435435
let expected = 0.0;
436436

437-
println!("constraint: {:?}", constraint);
438-
println!("setting: {:?}", setting);
439-
println!("actual: {:?}", actual);
440-
println!("expected: {:?}", expected);
437+
println!("constraint: {constraint:?}");
438+
println!("setting: {setting:?}");
439+
println!("actual: {actual:?}");
440+
println!("expected: {expected:?}");
441441

442442
assert_eq!(actual, expected);
443443
}

constraints/src/constraint/value.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ where
197197
let mut is_first = true;
198198
f.write_str("(")?;
199199
if let Some(ref exact) = &self.exact {
200-
f.write_fmt(format_args!("x == {:?}", exact))?;
200+
f.write_fmt(format_args!("x == {exact:?}"))?;
201201
is_first = false;
202202
}
203203
if let Some(ref ideal) = &self.ideal {
204204
if !is_first {
205205
f.write_str(" && ")?;
206206
}
207-
f.write_fmt(format_args!("x ~= {:?}", ideal))?;
207+
f.write_fmt(format_args!("x ~= {ideal:?}"))?;
208208
is_first = false;
209209
}
210210
if is_first {

constraints/src/constraint/value_range.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,23 +233,23 @@ where
233233
let mut is_first = true;
234234
f.write_str("(")?;
235235
if let Some(exact) = &self.exact {
236-
f.write_fmt(format_args!("x == {:?}", exact))?;
236+
f.write_fmt(format_args!("x == {exact:?}"))?;
237237
is_first = false;
238238
} else if let (Some(min), Some(max)) = (&self.min, &self.max) {
239-
f.write_fmt(format_args!("{:?} <= x <= {:?}", min, max))?;
239+
f.write_fmt(format_args!("{min:?} <= x <= {max:?}"))?;
240240
is_first = false;
241241
} else if let Some(min) = &self.min {
242-
f.write_fmt(format_args!("{:?} <= x", min))?;
242+
f.write_fmt(format_args!("{min:?} <= x"))?;
243243
is_first = false;
244244
} else if let Some(max) = &self.max {
245-
f.write_fmt(format_args!("x <= {:?}", max))?;
245+
f.write_fmt(format_args!("x <= {max:?}"))?;
246246
is_first = false;
247247
}
248248
if let Some(ideal) = &self.ideal {
249249
if !is_first {
250250
f.write_str(" && ")?;
251251
}
252-
f.write_fmt(format_args!("x ~= {:?}", ideal))?;
252+
f.write_fmt(format_args!("x ~= {ideal:?}"))?;
253253
is_first = false;
254254
}
255255
if is_first {

constraints/src/constraint/value_sequence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,14 @@ where
204204
let mut is_first = true;
205205
f.write_str("(")?;
206206
if let Some(ref exact) = &self.exact {
207-
f.write_fmt(format_args!("x == {:?}", exact))?;
207+
f.write_fmt(format_args!("x == {exact:?}"))?;
208208
is_first = false;
209209
}
210210
if let Some(ref ideal) = &self.ideal {
211211
if !is_first {
212212
f.write_str(" && ")?;
213213
}
214-
f.write_fmt(format_args!("x ~= {:?}", ideal))?;
214+
f.write_fmt(format_args!("x ~= {ideal:?}"))?;
215215
is_first = false;
216216
}
217217
if is_first {

constraints/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl std::fmt::Display for OverconstrainedError {
3131
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3232
write!(f, "Overconstrained property {:?}", self.constraint)?;
3333
if let Some(message) = self.message.as_ref() {
34-
write!(f, ": {}", message)?;
34+
write!(f, ": {message}")?;
3535
}
3636
Ok(())
3737
}
@@ -100,10 +100,10 @@ impl OverconstrainedError {
100100
[reason] => reason.clone(),
101101
[reasons @ .., reason] => {
102102
let reasons = reasons.join(", ");
103-
format!("either {}, or {}", reasons, reason)
103+
format!("either {reasons}, or {reason}")
104104
}
105105
};
106-
let message = Some(format!("Setting was {}.", formatted_reason));
106+
let message = Some(format!("Setting was {formatted_reason}."));
107107

108108
Self {
109109
constraint,

constraints/src/setting.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ pub enum MediaTrackSetting {
2828
impl std::fmt::Display for MediaTrackSetting {
2929
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3030
match self {
31-
Self::Bool(setting) => f.write_fmt(format_args!("{:?}", setting)),
32-
Self::Integer(setting) => f.write_fmt(format_args!("{:?}", setting)),
33-
Self::Float(setting) => f.write_fmt(format_args!("{:?}", setting)),
34-
Self::String(setting) => f.write_fmt(format_args!("{:?}", setting)),
31+
Self::Bool(setting) => f.write_fmt(format_args!("{setting:?}")),
32+
Self::Integer(setting) => f.write_fmt(format_args!("{setting:?}")),
33+
Self::Float(setting) => f.write_fmt(format_args!("{setting:?}")),
34+
Self::String(setting) => f.write_fmt(format_args!("{setting:?}")),
3535
}
3636
}
3737
}

data/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "webrtc-data"
33
version = "0.6.0"
44
authors = ["Rain Liu <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66
description = "A pure Rust implementation of WebRTC DataChannel API"
77
license = "MIT/Apache-2.0"
88
documentation = "https://docs.rs/webrtc-data"

dtls/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "webrtc-dtls"
33
version = "0.7.0"
44
authors = ["Rain Liu <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66
description = "A pure Rust implementation of DTLS"
77
license = "MIT/Apache-2.0"
88
documentation = "https://docs.rs/webrtc-dtls"

dtls/examples/dial/psk/dial_psk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async fn main() -> Result<(), Error> {
5757

5858
let conn = Arc::new(UdpSocket::bind("0.0.0.0:0").await?);
5959
conn.connect(server).await?;
60-
println!("connecting {}..", server);
60+
println!("connecting {server}..");
6161

6262
let config = Config {
6363
psk: Some(Arc::new(|hint: &[u8]| -> Result<Vec<u8>, Error> {

dtls/examples/dial/selfsign/dial_selfsign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ async fn main() -> Result<(), Error> {
5656

5757
let conn = Arc::new(UdpSocket::bind("0.0.0.0:0").await?);
5858
conn.connect(server).await?;
59-
println!("connecting {}..", server);
59+
println!("connecting {server}..");
6060

6161
// Generate a certificate and private key to secure the connection
6262
let certificate = Certificate::generate_self_signed(vec!["localhost".to_owned()])?;

dtls/examples/dial/verify/dial_verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async fn main() -> Result<(), Error> {
5757

5858
let conn = Arc::new(UdpSocket::bind("0.0.0.0:0").await?);
5959
conn.connect(server).await?;
60-
println!("connecting {}..", server);
60+
println!("connecting {server}..");
6161

6262
let certificate = hub::utilities::load_key_and_certificate(
6363
"examples/certificates/client.pem.private_key.pem".into(),

dtls/examples/hub/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "hub"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[dependencies]
77
util = { path = "../../../util", package = "webrtc-util", default-features = false, features = [

dtls/examples/hub/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Hub {
5050

5151
while let Ok(n) = conn.recv(&mut b).await {
5252
let msg = String::from_utf8(b[..n].to_vec())?;
53-
print!("Got message: {}", msg);
53+
print!("Got message: {msg}");
5454
}
5555

5656
Hub::unregister(conns, conn).await
@@ -67,9 +67,9 @@ impl Hub {
6767
}
6868

6969
if let Err(err) = conn.close().await {
70-
println!("Failed to disconnect: {} with err {}", remote_addr, err);
70+
println!("Failed to disconnect: {remote_addr} with err {err}");
7171
} else {
72-
println!("Disconnected: {} ", remote_addr);
72+
println!("Disconnected: {remote_addr} ");
7373
}
7474
}
7575

@@ -98,7 +98,7 @@ impl Hub {
9898
match reader.read_line(&mut msg) {
9999
Ok(0) => return,
100100
Err(err) => {
101-
println!("stdin read err: {}", err);
101+
println!("stdin read err: {err}");
102102
return;
103103
}
104104
_ => {}

dtls/examples/hub/src/utilities.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub async fn chat(conn: Arc<dyn Conn + Send + Sync>) -> Result<(), Error> {
4545

4646
while let Ok(n) = conn_rx.recv(&mut b).await {
4747
let msg = String::from_utf8(b[..n].to_vec()).expect("utf8");
48-
print!("Got message: {}", msg);
48+
print!("Got message: {msg}");
4949
}
5050

5151
Result::<(), Error>::Ok(())
@@ -58,7 +58,7 @@ pub async fn chat(conn: Arc<dyn Conn + Send + Sync>) -> Result<(), Error> {
5858
match reader.read_line(&mut msg) {
5959
Ok(0) => return Ok(()),
6060
Err(err) => {
61-
println!("stdin read err: {}", err);
61+
println!("stdin read err: {err}");
6262
return Ok(());
6363
}
6464
_ => {}

dtls/examples/listen/psk/listen_psk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async fn main() -> Result<(), Error> {
6666
..Default::default()
6767
};
6868

69-
println!("listening {}...\ntype 'exit' to shutdown gracefully", host);
69+
println!("listening {host}...\ntype 'exit' to shutdown gracefully");
7070

7171
let listener = Arc::new(listen(host, cfg).await?);
7272

dtls/examples/listen/selfsign/listen_selfsign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async fn main() -> Result<(), Error> {
6363
..Default::default()
6464
};
6565

66-
println!("listening {}...\ntype 'exit' to shutdown gracefully", host);
66+
println!("listening {host}...\ntype 'exit' to shutdown gracefully");
6767

6868
let listener = Arc::new(listen(host, cfg).await?);
6969

dtls/examples/listen/verify/listen_verify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async fn main() -> Result<(), Error> {
7575
..Default::default()
7676
};
7777

78-
println!("listening {}...\ntype 'exit' to shutdown gracefully", host);
78+
println!("listening {host}...\ntype 'exit' to shutdown gracefully");
7979

8080
let listener = Arc::new(listen(host, cfg).await?);
8181

@@ -100,7 +100,7 @@ async fn main() -> Result<(), Error> {
100100
h2.register(dtls_conn).await;
101101
}
102102
Err(err) => {
103-
println!("connecting failed with error: {}", err);
103+
println!("connecting failed with error: {err}");
104104
}
105105
}
106106
}

dtls/src/alert/alert_test.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,18 @@ fn test_alert() -> Result<()> {
3131
let result = Alert::unmarshal(&mut reader);
3232

3333
if let Some(err) = unmarshal_error {
34-
assert!(result.is_err(), "{} expected error: {}", name, err);
34+
assert!(result.is_err(), "{name} expected error: {err}");
3535
} else if let Ok(alert) = result {
36-
assert_eq!(
37-
wanted, alert,
38-
"{} expected {}, but got {}",
39-
name, wanted, alert
40-
);
36+
assert_eq!(wanted, alert, "{name} expected {wanted}, but got {alert}");
4137

4238
let mut data2: Vec<u8> = vec![];
4339
{
4440
let mut writer = BufWriter::<&mut Vec<u8>>::new(data2.as_mut());
4541
alert.marshal(&mut writer)?;
4642
}
47-
assert_eq!(
48-
data, data2,
49-
"{} expected {:?}, but got {:?}",
50-
name, data, data2
51-
);
43+
assert_eq!(data, data2, "{name} expected {data:?}, but got {data2:?}");
5244
} else {
53-
assert!(result.is_ok(), "{} expected Ok, but has error", name);
45+
assert!(result.is_ok(), "{name} expected Ok, but has error");
5446
}
5547
}
5648

dtls/src/change_cipher_spec/change_cipher_spec_test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ fn test_change_cipher_spec_round_trip() -> Result<()> {
1515
let cnew = ChangeCipherSpec::unmarshal(&mut reader)?;
1616
assert_eq!(
1717
c, cnew,
18-
"ChangeCipherSpec round trip: got {:?}, want {:?}",
19-
cnew, c
18+
"ChangeCipherSpec round trip: got {cnew:?}, want {c:?}"
2019
);
2120

2221
Ok(())

0 commit comments

Comments
 (0)