MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / StringZillableBinary

Interface StringZillableBinary

rust/stringzilla.rs:3094–3313  ·  view source on GitHub ↗

Trait for binary string operations that take a needle parameter. These operations include searching, splitting, and pattern matching. # Examples Basic usage on a string slice: ``` use stringzilla::sz::StringZillableBinary; let haystack = "Hello, world!"; assert_eq!(haystack.sz_find("world".as_bytes()), Some(7)); ```

Source from the content-addressed store, hash-verified

3092/// assert_eq!(haystack.sz_find("world".as_bytes()), Some(7));
3093/// ```
3094pub trait StringZillableBinary<'a, N>
3095where
3096 N: AsRef<[u8]> + 'a,
3097{
3098 /// Searches for the first occurrence of `needle` in `self`.
3099 ///
3100 /// # Examples
3101 ///
3102 /// ```
3103 /// use stringzilla::sz::StringZillableBinary;
3104 ///
3105 /// let haystack = "Hello, world!";
3106 /// assert_eq!(haystack.sz_find("world".as_bytes()), Some(7));
3107 /// ```
3108 fn sz_find(&self, needle: N) -> Option<usize>;
3109
3110 /// Searches for the last occurrence of `needle` in `self`.
3111 ///
3112 /// # Examples
3113 ///
3114 /// ```
3115 /// use stringzilla::sz::StringZillableBinary;
3116 ///
3117 /// let haystack = "Hello, world, world!";
3118 /// assert_eq!(haystack.sz_rfind("world".as_bytes()), Some(14));
3119 /// ```
3120 fn sz_rfind(&self, needle: N) -> Option<usize>;
3121
3122 /// Finds the index of the first character in `self` that is also present in `needles`.
3123 ///
3124 /// # Examples
3125 ///
3126 /// ```
3127 /// use stringzilla::sz::StringZillableBinary;
3128 ///
3129 /// let haystack = "Hello, world!";
3130 /// assert_eq!(haystack.sz_find_byte_from("aeiou".as_bytes()), Some(1));
3131 /// ```
3132 fn sz_find_byte_from(&self, needles: N) -> Option<usize>;
3133
3134 /// Finds the index of the last character in `self` that is also present in `needles`.
3135 ///
3136 /// # Examples
3137 ///
3138 /// ```
3139 /// use stringzilla::sz::StringZillableBinary;
3140 ///
3141 /// let haystack = "Hello, world!";
3142 /// assert_eq!(haystack.sz_rfind_byte_from("aeiou".as_bytes()), Some(8));
3143 /// ```
3144 fn sz_rfind_byte_from(&self, needles: N) -> Option<usize>;
3145
3146 /// Finds the index of the first character in `self` that is not present in `needles`.
3147 ///
3148 /// # Examples
3149 ///
3150 /// ```
3151 /// use stringzilla::sz::StringZillableBinary;

Callers

nothing calls this directly

Implementers 1

stringzilla.rsrust/stringzilla.rs

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…