diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-01-27 13:42:12 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-01-27 13:42:12 +0000 |
commit | 3cab3525e9c0bd743aa419d286de38d346776fbd (patch) | |
tree | f723baee45abb55068f6a75c45e1303748404493 /src | |
parent | e311ee31b819092a119fa24930ab5777d3c4fd71 (diff) | |
download | nitrokey-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.
Diffstat (limited to 'src')
-rw-r--r-- | src/util.rs | 2 |
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 { |