aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-23 03:46:09 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-23 04:02:24 +0000
commit5540ca5e76ffe5efe27d8819efb9e62066a10219 (patch)
treee2892e73f30a9f55f1d257b9e16f1ed7d99b9bed /src/config.rs
parente31009064eaaef9153ad5da3911aa0a939a050c2 (diff)
downloadnitrokey-rs-5540ca5e76ffe5efe27d8819efb9e62066a10219.tar.gz
nitrokey-rs-5540ca5e76ffe5efe27d8819efb9e62066a10219.tar.bz2
Refactor and clean up all code
This includes: - using idiomatic Rust - limiting the scope of unsafe blocks - simplifying code
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/config.rs b/src/config.rs
index 6aa6d10..329f7a6 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -30,21 +30,21 @@ pub struct RawConfig {
fn config_otp_slot_to_option(value: u8) -> Option<u8> {
if value < 3 {
- return Some(value);
+ Some(value)
+ } else {
+ None
}
- None
}
fn option_to_config_otp_slot(value: Option<u8>) -> Result<u8, Error> {
- match value {
- Some(value) => {
- if value < 3 {
- Ok(value)
- } else {
- Err(LibraryError::InvalidSlot.into())
- }
+ if let Some(value) = value {
+ if value < 3 {
+ Ok(value)
+ } else {
+ Err(LibraryError::InvalidSlot.into())
}
- None => Ok(255),
+ } else {
+ Ok(255)
}
}