]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
rust: Remove now unused byte_slice_is_c_like() utility.
authorIsis Lovecruft <isis@torproject.org>
Sat, 10 Feb 2018 02:20:50 +0000 (02:20 +0000)
committerIsis Lovecruft <isis@torproject.org>
Sat, 10 Feb 2018 02:31:07 +0000 (02:31 +0000)
src/rust/protover/ffi.rs
src/rust/tor_util/strings.rs

index 1df0b6675f414c536a1c2b4788cc9f9b7d20d806..e4cf0a7e88711db8f715f52c0fe941294e1c6533 100644 (file)
@@ -12,7 +12,6 @@ use std::ffi::CString;
 use protover::*;
 use smartlist::*;
 use tor_allocate::allocate_and_copy_string;
-use tor_util::strings::byte_slice_is_c_like;
 
 /// Translate C enums to Rust Proto enums, using the integer value of the C
 /// enum to map to its associated Rust enum
index dc4919d80fe38a48021420163eb98ed56f3ffcbb..4e26e7369c033c23716631f9c0f7fe2c029eea20 100644 (file)
@@ -3,45 +3,6 @@
 
 //! Utilities for working with static strings.
 
-/// A byte-array containing a single NUL byte (`b"\0"`).
-pub const NUL_BYTE: &'static [u8] = b"\0";
-
-/// Determine if a byte slice is a C-like string.
-///
-/// These checks guarantee that:
-///
-/// 1. there are no intermediate NUL bytes
-/// 2. the last byte *is* a NUL byte
-///
-/// # Warning
-///
-/// This function does _not_ guarantee that the bytes represent any valid
-/// encoding such as ASCII or UTF-8.
-///
-/// # Examples
-///
-/// ```
-/// # use tor_util::strings::byte_slice_is_c_like;
-/// #
-/// let bytes: &[u8] = b"foo bar baz";
-///
-/// assert!(byte_slice_is_c_like(&bytes) == false);
-///
-/// let bytes: &[u8] = b"foo\0bar baz";
-///
-/// assert!(byte_slice_is_c_like(&bytes) == false);
-///
-/// let bytes: &[u8] = b"foo bar baz\0";
-///
-/// assert!(byte_slice_is_c_like(&bytes) == true);
-/// ```
-pub fn byte_slice_is_c_like(bytes: &[u8]) -> bool {
-    if !bytes[..bytes.len() - 1].contains(&0x00) && bytes[bytes.len() - 1] == 0x00 {
-        return true;
-    }
-    false
-}
-
 /// Create a `CStr` from a literal byte slice, appending a NUL byte to it first.
 ///
 /// # Warning