aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-27 13:42:12 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-27 13:42:12 +0000
commit3cab3525e9c0bd743aa419d286de38d346776fbd (patch)
treef723baee45abb55068f6a75c45e1303748404493
parente311ee31b819092a119fa24930ab5777d3c4fd71 (diff)
downloadnitrokey-rs-3cab3525e9c0bd743aa419d286de38d346776fbd.tar.gz
nitrokey-rs-3cab3525e9c0bd743aa419d286de38d346776fbd.tar.bz2
Replace or with or_else in get_cstring
To avoid unnecessary function calls, we replace the or with an or_else in get_cstring.
-rw-r--r--src/util.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/util.rs b/src/util.rs
index d87cd7c..b7e8cd3 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -80,7 +80,7 @@ pub fn generate_password(length: usize) -> Result<Vec<u8>, Error> {
}
pub fn get_cstring<T: Into<Vec<u8>>>(s: T) -> Result<CString, Error> {
- CString::new(s).or(Err(LibraryError::InvalidString.into()))
+ CString::new(s).or_else(|_| Err(LibraryError::InvalidString.into()))
}
impl Into<i32> for LogLevel {