Skip to content

Commit 85dc806

Browse files
authored
Merge pull request #295 from Jakuje/clippy
context: Avoid clippy errors
2 parents 92382a3 + 752d405 commit 85dc806

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

cryptoki/src/context/general_purpose.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub enum Function {
145145

146146
impl Display for Function {
147147
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
148-
write!(f, "Function::{:?}", self)
148+
write!(f, "Function::{self:?}")
149149
}
150150
}
151151

cryptoki/tests/basic.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,7 @@ fn session_find_objects() -> testresult::TestResult {
862862
let key_template = vec![
863863
Attribute::Token(true),
864864
Attribute::Encrypt(true),
865-
Attribute::Label(format!("key_{}", i).as_bytes().to_vec()),
865+
Attribute::Label(format!("key_{i}").as_bytes().to_vec()),
866866
Attribute::ValueLen(32.into()),
867867
Attribute::Id("12345678".as_bytes().to_vec()), // reusing the same CKA_ID
868868
];
@@ -914,7 +914,7 @@ fn session_objecthandle_iterator() -> testresult::TestResult {
914914
Attribute::Token(true),
915915
Attribute::Encrypt(true),
916916
Attribute::ValueLen(32.into()),
917-
Attribute::Label(format!("key_{}", i).as_bytes().to_vec()),
917+
Attribute::Label(format!("key_{i}").as_bytes().to_vec()),
918918
Attribute::Id("12345678".as_bytes().to_vec()), // reusing the same CKA_ID
919919
];
920920

@@ -1088,27 +1088,27 @@ fn login_feast() {
10881088
let session = pkcs11.open_rw_session(slot).unwrap();
10891089
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
10901090
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
1091-
Err(e) => panic!("Bad error response: {}", e),
1091+
Err(e) => panic!("Bad error response: {e}"),
10921092
}
10931093
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
10941094
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
1095-
Err(e) => panic!("Bad error response: {}", e),
1095+
Err(e) => panic!("Bad error response: {e}"),
10961096
}
10971097
match session.login(UserType::User, Some(&AuthPin::new(USER_PIN.into()))) {
10981098
Ok(_) | Err(Error::Pkcs11(RvError::UserAlreadyLoggedIn, Function::Login)) => {}
1099-
Err(e) => panic!("Bad error response: {}", e),
1099+
Err(e) => panic!("Bad error response: {e}"),
11001100
}
11011101
match session.logout() {
11021102
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
1103-
Err(e) => panic!("Bad error response: {}", e),
1103+
Err(e) => panic!("Bad error response: {e}"),
11041104
}
11051105
match session.logout() {
11061106
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
1107-
Err(e) => panic!("Bad error response: {}", e),
1107+
Err(e) => panic!("Bad error response: {e}"),
11081108
}
11091109
match session.logout() {
11101110
Ok(_) | Err(Error::Pkcs11(RvError::UserNotLoggedIn, Function::Logout)) => {}
1111-
Err(e) => panic!("Bad error response: {}", e),
1111+
Err(e) => panic!("Bad error response: {e}"),
11121112
}
11131113
}));
11141114
}
@@ -1405,7 +1405,7 @@ fn is_initialized_test() {
14051405

14061406
match pkcs11.initialize(CInitializeArgs::OsThreads) {
14071407
Err(Error::AlreadyInitialized) => (),
1408-
Err(e) => panic!("Got unexpected error when initializing: {}", e),
1408+
Err(e) => panic!("Got unexpected error when initializing: {e}"),
14091409
Ok(()) => panic!("Initializing twice should not have been allowed"),
14101410
}
14111411
}
@@ -1517,7 +1517,7 @@ fn ro_rw_session_test() -> TestResult {
15171517
if let Error::Pkcs11(RvError::SessionReadOnly, _f) = e {
15181518
// as expected
15191519
} else {
1520-
panic!("Got wrong error code (expecting SessionReadOnly): {}", e);
1520+
panic!("Got wrong error code (expecting SessionReadOnly): {e}");
15211521
}
15221522
ro_session.logout()?;
15231523
}
@@ -2163,8 +2163,7 @@ fn wait_for_slot_event() {
21632163
Function::WaitForSlotEvent
21642164
))
21652165
),
2166-
"res = {:?}",
2167-
res
2166+
"res = {res:?}"
21682167
);
21692168
}
21702169

0 commit comments

Comments
 (0)