A post-modern development environment.
0

Configure Feed

Select the types of activity you want to include in your feed.

stdx: Add must_use and inline attributes to regex and grapheme helpers

+10
+10
helix-stdx/src/rope.rs
··· 13 13 pub trait RopeSliceExt<'a>: Sized { 14 14 fn ends_with(self, text: &str) -> bool; 15 15 fn starts_with(self, text: &str) -> bool; 16 + #[must_use] 16 17 fn regex_input(self) -> RegexInput<RopeyCursor<'a>>; 18 + #[must_use] 17 19 fn regex_input_at_bytes<R: RangeBounds<usize>>( 18 20 self, 19 21 byte_range: R, 20 22 ) -> RegexInput<RopeyCursor<'a>>; 23 + #[must_use] 21 24 fn regex_input_at<R: RangeBounds<usize>>(self, char_range: R) -> RegexInput<RopeyCursor<'a>>; 22 25 fn first_non_whitespace_char(self) -> Option<usize>; 23 26 fn last_non_whitespace_char(self) -> Option<usize>; ··· 137 140 /// let graphemes: Vec<_> = text.graphemes().collect(); 138 141 /// assert_eq!(graphemes.as_slice(), &["😶‍🌫️", "🏴‍☠️", "🖼️"]); 139 142 /// ``` 143 + #[inline] 144 + #[must_use] 140 145 fn graphemes(self) -> RopeGraphemes<'a> { 141 146 self.graphemes_at(0) 142 147 } ··· 154 159 /// let graphemes: Vec<_> = text.graphemes_rev().collect(); 155 160 /// assert_eq!(graphemes.as_slice(), &["🖼️", "🏴‍☠️", "😶‍🌫️"]); 156 161 /// ``` 162 + #[must_use] 157 163 fn graphemes_rev(self) -> RopeGraphemes<'a>; 158 164 /// Returns an iterator over the grapheme clusters in the slice at the given byte index. 159 165 /// ··· 170 176 /// let graphemes: Vec<_> = text.slice(..).graphemes_at(27).reversed().collect(); 171 177 /// assert_eq!(graphemes.as_slice(), &["🏴‍☠️", "😶‍🌫️"]); 172 178 /// ``` 179 + #[must_use] 173 180 fn graphemes_at(self, byte_idx: usize) -> RopeGraphemes<'a>; 174 181 /// Returns an iterator over the grapheme clusters in a rope and the byte index where each 175 182 /// grapheme cluster starts. 176 183 /// 177 184 /// Same as `grapheme_indices_at(0)`. 185 + #[inline] 186 + #[must_use] 178 187 fn grapheme_indices(self) -> RopeGraphemeIndices<'a> { 179 188 self.grapheme_indices_at(0) 180 189 } ··· 199 208 /// &[(27, "🖼️".into()), (14, "🏴‍☠️".into()), (0, "😶‍🌫️".into())] 200 209 /// ); 201 210 /// ``` 211 + #[must_use] 202 212 fn grapheme_indices_at(self, byte_idx: usize) -> RopeGraphemeIndices<'a>; 203 213 /// Finds the byte index of the next grapheme boundary after `byte_idx`. 204 214 ///