@@ -74,8 +74,9 @@ pub fn camel_case_start(s: &str) -> StrIndex {
7474/// Returns `StrIndex` of the last camel-case component of `s[idx..]`.
7575///
7676/// ```
77- /// assert_eq!(camel_case_start("AbcDef", 0), StrIndex::new(0, 0));
78- /// assert_eq!(camel_case_start("AbcDef", 1), StrIndex::new(3, 3));
77+ /// # use clippy_utils::str_utils::{camel_case_start_from_idx, StrIndex};
78+ /// assert_eq!(camel_case_start_from_idx("AbcDef", 0), StrIndex::new(0, 0));
79+ /// assert_eq!(camel_case_start_from_idx("AbcDef", 1), StrIndex::new(3, 3));
7980/// ```
8081pub fn camel_case_start_from_idx ( s : & str , start_idx : usize ) -> StrIndex {
8182 let char_count = s. chars ( ) . count ( ) ;
@@ -119,7 +120,10 @@ pub fn camel_case_start_from_idx(s: &str, start_idx: usize) -> StrIndex {
119120/// Get the indexes of camel case components of a string `s`
120121///
121122/// ```
122- /// assert_eq!(camel_case_indexes("AbcDef"), vec![StrIndex::new(0, 0), StrIndex::new(3, 3)])
123+ /// # use clippy_utils::str_utils::{camel_case_indexes, StrIndex};
124+ /// assert_eq!(camel_case_indexes("AbcDef"), vec![StrIndex::new(0, 0), StrIndex::new(3, 3),
125+ /// StrIndex::new(6, 6)]);
126+ /// assert_eq!(camel_case_indexes("abcDef"), vec![StrIndex::new(3, 3), StrIndex::new(6, 6)]);
123127/// ```
124128pub fn camel_case_indexes ( s : & str ) -> Vec < StrIndex > {
125129 let mut result = Vec :: new ( ) ;
@@ -138,6 +142,7 @@ pub fn camel_case_indexes(s: &str) -> Vec<StrIndex> {
138142/// Split camel case string into a vector of its components
139143///
140144/// ```
145+ /// # use clippy_utils::str_utils::{camel_case_split, StrIndex};
141146/// assert_eq!(camel_case_split("AbcDef"), vec!["Abc", "Def"]);
142147/// ```
143148pub fn camel_case_split ( s : & str ) -> Vec < & str > {
@@ -288,17 +293,16 @@ mod test {
288293 assert_eq ! ( camel_case_until( "ABCD" ) , StrIndex :: new( 0 , 0 ) ) ;
289294 }
290295
296+ #[ test]
297+ fn camel_case_start_from_idx_full ( ) {
298+ assert_eq ! ( camel_case_start_from_idx( "AbcDef" , 0 ) , StrIndex :: new( 0 , 0 ) ) ;
299+ assert_eq ! ( camel_case_start_from_idx( "AbcDef" , 1 ) , StrIndex :: new( 3 , 3 ) ) ;
300+ assert_eq ! ( camel_case_start_from_idx( "AbcDef" , 4 ) , StrIndex :: new( 6 , 6 ) ) ;
301+ }
302+
291303 #[ test]
292304 fn camel_case_indexes_full ( ) {
293- assert_eq ! (
294- camel_case_indexes( "AbcDef" ) ,
295- vec![ StrIndex :: new( 0 , 0 ) , StrIndex :: new( 3 , 3 ) ]
296- ) ;
297- assert_eq ! (
298- camel_case_indexes( "abcDef" ) ,
299- vec![ StrIndex :: new( 0 , 0 ) , StrIndex :: new( 3 , 3 ) ]
300- ) ;
301- assert_eq ! ( camel_case_indexes( "Abc\u{f6} \u{f6} DD" ) , vec![ StrIndex :: new( 5 , 7 ) ] ) ;
305+ assert_eq ! ( camel_case_indexes( "Abc\u{f6} \u{f6} DD" ) , vec![ StrIndex :: new( 7 , 9 ) ] ) ;
302306 }
303307
304308 #[ test]
0 commit comments