diff options
author | Isis Lovecruft <isis@torproject.org> | 2018-02-10 01:21:31 +0000 |
---|---|---|
committer | Isis Lovecruft <isis@torproject.org> | 2018-02-10 01:21:31 +0000 |
commit | 45c59eff6c0b261d1f868eb22e0bd36a39dfdbb3 (patch) | |
tree | 23fb9c5b36d3cdd35844f5e93d9e268ff3c10a77 /src/rust | |
parent | d9826b0a30f42754dc5764ce02c7b0271d996c92 (diff) | |
download | tor-45c59eff6c0b261d1f868eb22e0bd36a39dfdbb3.tar.gz tor-45c59eff6c0b261d1f868eb22e0bd36a39dfdbb3.zip |
rust: Replace two `unwrap()`s in FFI code with `unwrap_or()`s.
Diffstat (limited to 'src/rust')
-rw-r--r-- | src/rust/protover/ffi.rs | 2 | ||||
-rw-r--r-- | src/rust/protover/protover.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/rust/protover/ffi.rs b/src/rust/protover/ffi.rs index d724c102d3..2ee0286ecf 100644 --- a/src/rust/protover/ffi.rs +++ b/src/rust/protover/ffi.rs @@ -232,7 +232,7 @@ pub extern "C" fn protover_compute_for_old_tor(version: *const c_char) -> *const // we can see that the bytes we're passing into it 1) are valid UTF-8, // 2) have no intermediate NUL bytes, and 3) are terminated with a NUL // byte. - supported = CStr::from_bytes_with_nul(elder_protocols).unwrap(); + supported = CStr::from_bytes_with_nul(elder_protocols).unwrap_or(empty); supported.as_ptr() } diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs index 826f1b73f1..25f776aed4 100644 --- a/src/rust/protover/protover.rs +++ b/src/rust/protover/protover.rs @@ -110,7 +110,7 @@ pub fn get_supported_protocols() -> &'static str { // The `unwrap` is safe becauase we SUPPORTED_PROTOCOLS is under // our control. str::from_utf8(&SUPPORTED_PROTOCOLS[..SUPPORTED_PROTOCOLS.len() - 1]) - .unwrap() + .unwrap_or("") } pub struct SupportedProtocols(HashMap<Proto, Versions>); |