1 /// Returns the index of the character after the first camel-case component of `s`.
3 pub fn until(s: &str) -> usize {
4 let mut iter = s.char_indices();
5 if let Some((_, first)) = iter.next() {
6 if !first.is_uppercase() {
21 } else if c.is_uppercase() {
24 } else if !c.is_lowercase() {
35 /// Returns index of the last camel-case component of `s`.
37 pub fn from(s: &str) -> usize {
38 let mut iter = s.char_indices().rev();
39 if let Some((_, first)) = iter.next() {
40 if !first.is_lowercase() {
47 let mut last_i = s.len();
53 } else if !c.is_lowercase() {
56 } else if c.is_lowercase() {
67 use super::{from, until};
71 assert_eq!(from("AbcDef"), 0);
72 assert_eq!(from("Abc"), 0);
77 assert_eq!(from("abcDef"), 3);
78 assert_eq!(from("aDbc"), 1);
83 assert_eq!(from("AbcDef_"), 7);
84 assert_eq!(from("AbcDD"), 5);
89 assert_eq!(from("ABCD"), 4);
94 assert_eq!(until("AbcDef"), 6);
95 assert_eq!(until("Abc"), 3);
100 assert_eq!(until("abcDef"), 0);
101 assert_eq!(until("aDbc"), 0);
106 assert_eq!(until("AbcDef_"), 6);
107 assert_eq!(until("CallTypeC"), 8);
108 assert_eq!(until("AbcDD"), 3);
113 assert_eq!(until("ABCD"), 0);