1 /// Returns the index of the character after the first camel-case component of `s`.
2 pub fn until(s: &str) -> usize {
3 let mut iter = s.char_indices();
4 if let Some((_, first)) = iter.next() {
5 if !first.is_uppercase() {
20 } else if c.is_uppercase() {
23 } else if !c.is_lowercase() {
34 /// Returns index of the last camel-case component of `s`.
35 pub fn from(s: &str) -> usize {
36 let mut iter = s.char_indices().rev();
37 if let Some((_, first)) = iter.next() {
38 if !first.is_lowercase() {
45 let mut last_i = s.len();
51 } else if !c.is_lowercase() {
54 } else if c.is_lowercase() {
65 use super::{from, until};
69 assert_eq!(from("AbcDef"), 0);
70 assert_eq!(from("Abc"), 0);
75 assert_eq!(from("abcDef"), 3);
76 assert_eq!(from("aDbc"), 1);
81 assert_eq!(from("AbcDef_"), 7);
82 assert_eq!(from("AbcDD"), 5);
87 assert_eq!(from("ABCD"), 4);
92 assert_eq!(until("AbcDef"), 6);
93 assert_eq!(until("Abc"), 3);
98 assert_eq!(until("abcDef"), 0);
99 assert_eq!(until("aDbc"), 0);
104 assert_eq!(until("AbcDef_"), 6);
105 assert_eq!(until("CallTypeC"), 8);
106 assert_eq!(until("AbcDD"), 3);
111 assert_eq!(until("ABCD"), 0);