diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-02-08 17:26:26 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-02-08 17:29:50 -0500 |
commit | d8307cb0e99d28daa4011e4e9d94e3f8c56cba23 (patch) | |
tree | 4e82d15238612f136a7b07425393722401b8ca8d /src/rust/protover/protover.rs | |
parent | 8d142e2322398a799a9554daf566b6fd856d7dd8 (diff) | |
download | tor-d8307cb0e99d28daa4011e4e9d94e3f8c56cba23.tar.gz tor-d8307cb0e99d28daa4011e4e9d94e3f8c56cba23.zip |
Remove new unsafe {} use.
Rationale: this helps for performance only, but we don't actually
have any reason to think that the checks here are
performance-critical. Let's not normalize the use of unsafe {}.
Diffstat (limited to 'src/rust/protover/protover.rs')
-rw-r--r-- | src/rust/protover/protover.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs index 1680d3394e..f3a5ea23ef 100644 --- a/src/rust/protover/protover.rs +++ b/src/rust/protover/protover.rs @@ -106,10 +106,11 @@ impl FromStr for Proto { /// "HSDir=1-1 LinkAuth=1" /// pub fn get_supported_protocols() -> &'static str { - unsafe { - // The `len() - 1` is to remove the NUL byte. - str::from_utf8_unchecked(&SUPPORTED_PROTOCOLS[..SUPPORTED_PROTOCOLS.len() - 1]) - } + // The `len() - 1` is to remove the NUL byte. + // The `unwrap` is safe becauase we SUPPORTED_PROTOCOLS is under + // our control. + str::from_utf8(&SUPPORTED_PROTOCOLS[..SUPPORTED_PROTOCOLS.len() - 1]) + .unwrap() } /// Translates a vector representation of a protocol list into a HashMap |