Skip to content

Commit ab8d477

Browse files
committed
simplify MechanismInfo fmt
Signed-off-by: nikita.kalinichenko <[email protected]>
1 parent 991079d commit ab8d477

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

cryptoki/src/mechanism/mechanism_info.rs

+13-15
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,19 @@ impl MechanismInfo {
220220

221221
impl std::fmt::Display for MechanismInfo {
222222
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
223-
let flags = format!("{0:#?}", self.flags);
224-
let key_size_info = match self.min_key_size == 0 && self.max_key_size == 0 {
225-
true => String::new(),
226-
false => {
227-
if self.max_key_size == 0 {
228-
format!(", min_key_size={}", self.min_key_size)
229-
} else {
230-
format!(
231-
", min_key_size={}, max_key_size={}",
232-
self.min_key_size, self.max_key_size
233-
)
234-
}
235-
}
236-
};
237-
write!(f, "{}{}", flags, key_size_info)
223+
write!(f, "{:#?}", self.flags)?;
224+
225+
if self.min_key_size == 0 && self.max_key_size == 0 {
226+
return Ok(());
227+
}
228+
229+
write!(f, ", min_key_size={}", self.min_key_size)?;
230+
231+
if self.max_key_size != 0 {
232+
write!(f, ", max_key_size={}", self.max_key_size)?;
233+
}
234+
235+
Ok(())
238236
}
239237
}
240238

0 commit comments

Comments
 (0)