18
18
use std:: char:: ToUppercase ;
19
19
use std:: iter:: Peekable ;
20
20
21
- /// Converts any case into lower case ignoring seperators .
21
+ /// Converts any case into lower case ignoring separators .
22
22
///
23
23
/// # Example
24
24
/// ```rust
@@ -59,7 +59,7 @@ pub fn is_lower_case(string: &str) -> bool {
59
59
string == to_lower_case ( string)
60
60
}
61
61
62
- /// Converts any case into UPPER CASE ignoring seperators .
62
+ /// Converts any case into UPPER CASE ignoring separators .
63
63
///
64
64
/// # Example
65
65
/// ```rust
@@ -120,7 +120,7 @@ pub fn is_upper_case(string: &str) -> bool {
120
120
pub fn to_sentence_case ( string : & str ) -> String {
121
121
string
122
122
. chars ( )
123
- . map ( |c| swap_seperator ( c, ' ' ) )
123
+ . map ( |c| swap_separator ( c, ' ' ) )
124
124
. break_camel ( ' ' )
125
125
. flat_map ( char:: to_lowercase)
126
126
. collect ( )
@@ -163,7 +163,7 @@ pub fn is_sentence_case(string: &str) -> bool {
163
163
pub fn to_title_case ( string : & str ) -> String {
164
164
string
165
165
. chars ( )
166
- . map ( |c| swap_seperator ( c, ' ' ) )
166
+ . map ( |c| swap_separator ( c, ' ' ) )
167
167
. break_camel ( ' ' )
168
168
. flat_map ( char:: to_lowercase)
169
169
. capitalize_words ( )
@@ -289,7 +289,7 @@ pub fn is_pascal_case(string: &str) -> bool {
289
289
pub fn to_kebab_case ( string : & str ) -> String {
290
290
string
291
291
. chars ( )
292
- . map ( |c| swap_seperator ( c, '-' ) )
292
+ . map ( |c| swap_separator ( c, '-' ) )
293
293
. break_camel ( '-' )
294
294
. flat_map ( char:: to_lowercase)
295
295
. collect ( )
@@ -332,7 +332,7 @@ pub fn is_kebab_case(string: &str) -> bool {
332
332
pub fn to_train_case ( string : & str ) -> String {
333
333
string
334
334
. chars ( )
335
- . map ( |c| swap_seperator ( c, '-' ) )
335
+ . map ( |c| swap_separator ( c, '-' ) )
336
336
. break_camel ( '-' )
337
337
. flat_map ( char:: to_lowercase)
338
338
. capitalize_words ( )
@@ -376,7 +376,7 @@ pub fn is_train_case(string: &str) -> bool {
376
376
pub fn to_snake_case ( string : & str ) -> String {
377
377
string
378
378
. chars ( )
379
- . map ( |c| swap_seperator ( c, '_' ) )
379
+ . map ( |c| swap_separator ( c, '_' ) )
380
380
. break_camel ( '_' )
381
381
. flat_map ( char:: to_lowercase)
382
382
. collect ( )
@@ -419,7 +419,7 @@ pub fn is_snake_case(string: &str) -> bool {
419
419
pub fn to_constant_case ( string : & str ) -> String {
420
420
string
421
421
. chars ( )
422
- . map ( |c| swap_seperator ( c, '_' ) )
422
+ . map ( |c| swap_separator ( c, '_' ) )
423
423
. break_camel ( '_' )
424
424
. flat_map ( char:: to_uppercase)
425
425
. collect ( )
@@ -443,18 +443,18 @@ pub fn is_constant_case(string: &str) -> bool {
443
443
string == to_constant_case ( string)
444
444
}
445
445
446
- /// Checks if a character is a seperator .
446
+ /// Checks if a character is a separator .
447
447
#[ inline]
448
- fn is_seperator ( c : char ) -> bool {
448
+ fn is_separator ( c : char ) -> bool {
449
449
c == ' ' || c == '-' || c == '_'
450
450
}
451
451
452
- /// Swaps the current character (which may be a seperator ), with the seperator
453
- /// of choice. Currently ' ', '-', and '_' are considered seperators which will
452
+ /// Swaps the current character (which may be a separator ), with the separator
453
+ /// of choice. Currently ' ', '-', and '_' are considered separators which will
454
454
/// be swapped.
455
455
#[ inline]
456
- fn swap_seperator ( c : char , sep : char ) -> char {
457
- if is_seperator ( c) {
456
+ fn swap_separator ( c : char , sep : char ) -> char {
457
+ if is_separator ( c) {
458
458
sep
459
459
} else {
460
460
c
@@ -477,9 +477,9 @@ fn scan_to_camel(state: &mut (bool, Option<char>), curr: char) -> Option<String>
477
477
// capitalize it and mark the state as finished.
478
478
state. 0 = false ;
479
479
Some ( curr. to_uppercase ( ) . collect ( ) )
480
- } else if is_seperator ( curr) {
481
- // If the current character is a seperator , mark the state to capitalize
482
- // the next character and remove the seperator .
480
+ } else if is_separator ( curr) {
481
+ // If the current character is a separator , mark the state to capitalize
482
+ // the next character and remove the separator .
483
483
state. 0 = true ;
484
484
Some ( "" . to_owned ( ) )
485
485
} else if !last. map_or ( false , char:: is_lowercase) {
@@ -510,12 +510,12 @@ trait Extras: Iterator<Item=char> {
510
510
}
511
511
512
512
/// Uses the `CapitalizeWords` type to capitilize individual words seperated
513
- /// by a seperator (as defined by `is_seperator `).
513
+ /// by a separator (as defined by `is_separator `).
514
514
#[ inline]
515
515
fn capitalize_words ( self ) -> CapitalizeWords < Self > where Self : Sized {
516
516
let mut iter = self . peekable ( ) ;
517
- // If the first character is not a seperator , we want to capitilize it.
518
- let cap = !iter. peek ( ) . cloned ( ) . map_or ( false , is_seperator ) ;
517
+ // If the first character is not a separator , we want to capitilize it.
518
+ let cap = !iter. peek ( ) . cloned ( ) . map_or ( false , is_separator ) ;
519
519
CapitalizeWords {
520
520
iter : iter,
521
521
cap : cap,
@@ -542,7 +542,7 @@ impl<I> Iterator for BreakCamel<I> where I: Iterator<Item=char> {
542
542
543
543
#[ inline]
544
544
fn next ( & mut self ) -> Option < Self :: Item > {
545
- // If we have been signaled to break, the next item is a seperator and we
545
+ // If we have been signaled to break, the next item is a separator and we
546
546
// should disable break mode.
547
547
if self . br {
548
548
self . br = false ;
@@ -605,10 +605,10 @@ impl<I> Iterator for CapitalizeWords<I> where I: Iterator<Item=char> {
605
605
self . upper = Some ( c. to_uppercase ( ) ) ;
606
606
// We want it to loop back here…
607
607
} else {
608
- // Otherwise return the character, but if it is a seperator , and the
609
- // next character is not a seperator —signal the next character should
608
+ // Otherwise return the character, but if it is a separator , and the
609
+ // next character is not a separator —signal the next character should
610
610
// be capitalized.
611
- if is_seperator ( c) && !self . iter . peek ( ) . cloned ( ) . map_or ( false , is_seperator ) {
611
+ if is_separator ( c) && !self . iter . peek ( ) . cloned ( ) . map_or ( false , is_separator ) {
612
612
self . cap = true ;
613
613
}
614
614
return Some ( c) ;
0 commit comments