Skip to content

Commit 0fb5293

Browse files
committed
apply clippy suggestions.
the `new` method in credential and assertion maybe failed with nullptr, but now always assume alloc not fail
1 parent 2d39349 commit 0fb5293

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

fido2-rs/src/assertion.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ impl_assertion_set!(AssertRequest, 0.ptr);
133133

134134
impl AssertRequest {
135135
/// Return a [AssertRequest]
136+
#[allow(clippy::new_without_default)]
136137
pub fn new() -> AssertRequest {
137138
unsafe {
138139
let assert = ffi::fido_assert_new();
@@ -151,6 +152,7 @@ impl_assertion_set!(AssertVerifier, 0.ptr);
151152

152153
impl AssertVerifier {
153154
/// Return a [AssertVerifier] for verify.
155+
#[allow(clippy::new_without_default)]
154156
pub fn new() -> AssertVerifier {
155157
unsafe {
156158
let assert = ffi::fido_assert_new();
@@ -428,7 +430,7 @@ impl Assertions {
428430
let count = self.count();
429431

430432
AssertionIter {
431-
asserts: &self,
433+
asserts: self,
432434
idx: 0,
433435
count,
434436
}

fido2-rs/src/credentials.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ impl Drop for Credential {
1818

1919
impl Credential {
2020
/// Create a new credential
21+
#[allow(clippy::new_without_default)]
2122
pub fn new() -> Self {
2223
unsafe {
2324
let cred = ffi::fido_cred_new();

fido2-rs/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@
3838
//! ```rust,no_run
3939
//! use fido2_rs::device::DeviceList;
4040
//!
41-
//! fn main() {
42-
//! let list = DeviceList::list_devices(4);
43-
//!
44-
//! for dev in list {
45-
//! println!("{:?}", dev.path);
46-
//! }
41+
//! let list = DeviceList::list_devices(4);
42+
//! for dev in list {
43+
//! println!("{:?}", dev.path);
4744
//! }
45+
//!
4846
//! ```
4947
//!
5048
//! ## Make a credential

libfido2-sys/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn main() -> Result<()> {
5151
return Ok(());
5252
}
5353

54-
if let Ok(_) = env::var("FIDO2_USE_PKG_CONFIG") {
54+
if env::var("FIDO2_USE_PKG_CONFIG").is_ok() {
5555
find_pkg()?;
5656

5757
return Ok(());
@@ -92,7 +92,7 @@ fn main() -> Result<()> {
9292
fn verify_sha256(content: &[u8]) -> bool {
9393
let sha256 = Sha256::digest(content);
9494

95-
&*sha256 == hex::decode(SHA256).unwrap()
95+
*sha256 == hex::decode(SHA256).unwrap()
9696
}
9797

9898
/// for windows and msvc, use pre-build

0 commit comments

Comments
 (0)