@@ -834,26 +834,23 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
834
834
fn is_camel_case ( cx : ty:: ctxt , ident : ast:: ident ) -> bool {
835
835
let ident = cx. sess . str_of ( ident) ;
836
836
assert !ident. is_empty ( ) ;
837
- let ident = ident_without_trailing_underscores ( ident) ;
837
+ let ident = ident_without_trailing_underscores ( * ident) ;
838
838
let ident = ident_without_leading_underscores ( ident) ;
839
839
char:: is_uppercase ( str:: char_at ( ident, 0 ) ) &&
840
840
!ident. contains_char ( '_' )
841
841
}
842
842
843
- fn ident_without_trailing_underscores ( + ident : ~ str ) -> ~ str {
843
+ fn ident_without_trailing_underscores ( ident : & r/ str ) -> & r/ str {
844
844
match str:: rfind ( ident, |c| c != '_' ) {
845
- Some ( idx) => ( ident) . slice ( 0 , idx + 1 ) ,
846
- None => { ident } // all underscores
845
+ Some ( idx) => str :: view ( ident, 0 , idx + 1 ) ,
846
+ None => ident, // all underscores
847
847
}
848
848
}
849
849
850
- fn ident_without_leading_underscores ( + ident : ~ str ) -> ~ str {
850
+ fn ident_without_leading_underscores ( ident : & r/ str ) -> & r/ str {
851
851
match str:: find ( ident, |c| c != '_' ) {
852
- Some ( idx) => ident. slice ( idx, ident. len ( ) ) ,
853
- None => {
854
- // all underscores
855
- ident
856
- }
852
+ Some ( idx) => str:: view ( ident, idx, ident. len ( ) ) ,
853
+ None => ident // all underscores
857
854
}
858
855
}
859
856
0 commit comments