diff options
author | Isis Lovecruft <isis@torproject.org> | 2018-02-10 02:20:50 +0000 |
---|---|---|
committer | Isis Lovecruft <isis@torproject.org> | 2018-02-10 02:31:07 +0000 |
commit | a4797a7e62f3f53326b3d33fa72b23f1dc0bc061 (patch) | |
tree | fc2788812202fc4e7935cc13e397d860f5589c95 /src/rust/tor_util | |
parent | 081e99c16f754ffd5605acdfddec527a2a426ed8 (diff) | |
download | tor-a4797a7e62f3f53326b3d33fa72b23f1dc0bc061.tar.gz tor-a4797a7e62f3f53326b3d33fa72b23f1dc0bc061.zip |
rust: Remove now unused byte_slice_is_c_like() utility.
Diffstat (limited to 'src/rust/tor_util')
-rw-r--r-- | src/rust/tor_util/strings.rs | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/rust/tor_util/strings.rs b/src/rust/tor_util/strings.rs index dc4919d80f..4e26e7369c 100644 --- a/src/rust/tor_util/strings.rs +++ b/src/rust/tor_util/strings.rs @@ -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 |