Skip to content

Commit ea9189f

Browse files
larseggertNot-Nik
authored andcommitted
chore: Be more idiomatic (#3463)
1 parent 1ad1bad commit ea9189f

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn build_nss(dir: PathBuf) {
168168
String::from("--static"),
169169
];
170170
let target = env::var("TARGET").unwrap();
171-
if target.strip_prefix("aarch64-").is_some() {
171+
if target.starts_with("aarch64-") {
172172
build_nss.push(String::from("--target=arm64"));
173173
}
174174
let status = Command::new(get_bash())

src/agent.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ impl SecretAgentPreInfo {
364364
}
365365

366366
#[must_use]
367-
pub const fn alpn(&self) -> Option<&String> {
368-
self.alpn.as_ref()
367+
pub fn alpn(&self) -> Option<&str> {
368+
self.alpn.as_deref()
369369
}
370370
}
371371

@@ -428,8 +428,8 @@ impl SecretAgentInfo {
428428
self.ech_accepted
429429
}
430430
#[must_use]
431-
pub const fn alpn(&self) -> Option<&String> {
432-
self.alpn.as_ref()
431+
pub fn alpn(&self) -> Option<&str> {
432+
self.alpn.as_deref()
433433
}
434434
#[must_use]
435435
pub const fn signature_scheme(&self) -> SignatureScheme {

src/agentio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ impl RecordList {
131131
}
132132

133133
impl Deref for RecordList {
134-
type Target = Vec<Record>;
135-
fn deref(&self) -> &Vec<Record> {
134+
type Target = [Record];
135+
fn deref(&self) -> &[Record] {
136136
&self.records
137137
}
138138
}

src/cert.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ impl CertificateInfo {
9393
}
9494

9595
#[must_use]
96-
pub const fn stapled_ocsp_responses(&self) -> Option<&Vec<Vec<u8>>> {
97-
self.stapled_ocsp_responses.as_ref()
96+
pub fn stapled_ocsp_responses(&self) -> Option<&[Vec<u8>]> {
97+
self.stapled_ocsp_responses.as_deref()
9898
}
9999

100100
#[must_use]
101-
pub const fn signed_cert_timestamp(&self) -> Option<&Vec<u8>> {
102-
self.signed_cert_timestamp.as_ref()
101+
pub fn signed_cert_timestamp(&self) -> Option<&[u8]> {
102+
self.signed_cert_timestamp.as_deref()
103103
}
104104
}

tests/agent.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ fn alpn() {
278278
connect(&mut client, &mut server);
279279

280280
let expected = Some(String::from("alpn"));
281-
assert_eq!(expected.as_ref(), client.info().unwrap().alpn());
282-
assert_eq!(expected.as_ref(), server.info().unwrap().alpn());
281+
assert_eq!(expected.as_deref(), client.info().unwrap().alpn());
282+
assert_eq!(expected.as_deref(), server.info().unwrap().alpn());
283283
}
284284

285285
#[test]
@@ -308,8 +308,8 @@ fn alpn_multi() {
308308
connect(&mut client, &mut server);
309309

310310
let expected = Some(String::from("alpn"));
311-
assert_eq!(expected.as_ref(), client.info().unwrap().alpn());
312-
assert_eq!(expected.as_ref(), server.info().unwrap().alpn());
311+
assert_eq!(expected.as_deref(), client.info().unwrap().alpn());
312+
assert_eq!(expected.as_deref(), server.info().unwrap().alpn());
313313
}
314314

315315
#[test]
@@ -327,8 +327,8 @@ fn alpn_server_pref() {
327327
connect(&mut client, &mut server);
328328

329329
let expected = Some(String::from("alpn"));
330-
assert_eq!(expected.as_ref(), client.info().unwrap().alpn());
331-
assert_eq!(expected.as_ref(), server.info().unwrap().alpn());
330+
assert_eq!(expected.as_deref(), client.info().unwrap().alpn());
331+
assert_eq!(expected.as_deref(), server.info().unwrap().alpn());
332332
}
333333

334334
#[test]

0 commit comments

Comments
 (0)