Skip to content

Commit

Permalink
clippy stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jordy25519 committed May 15, 2023
1 parent ec36cae commit a3a3a42
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//!

/// Word boundary separators
const SEPARATORS: &'static str = "-_";
const SEPARATORS: &str = "-_";

pub trait PascalCaseExt {
fn to_pascal_case(&self) -> String;
Expand All @@ -14,7 +14,7 @@ impl PascalCaseExt for String {
let mut s = String::new();
let mut capitalise_next = true; // always on first char

let mut char_stream = self.chars().into_iter().peekable();
let mut char_stream = self.chars().peekable();
while let Some(current_char) = char_stream.next() {
if SEPARATORS.contains(current_char) | current_char.is_numeric() {
capitalise_next = true;
Expand Down Expand Up @@ -58,11 +58,11 @@ impl SnakeCaseExt for String {
fn to_snake_case(&self) -> String {
let mut s = String::new();
let mut was_sep = false;
if let Some(c) = self.chars().nth(0) {
if let Some(c) = self.chars().next() {
was_sep = SEPARATORS.contains(c);
s.push(c.to_lowercase().next().unwrap());
}
for c in self.chars().skip(1).into_iter() {
for c in self.chars().skip(1) {
if c.is_lowercase() {
was_sep = false;
s.push(c);
Expand All @@ -89,10 +89,10 @@ pub trait ShoutySnakeCaseExt {
impl ShoutySnakeCaseExt for String {
fn to_shouty_snake_case(&self) -> String {
let mut s = String::new();
if let Some(c) = self.chars().nth(0) {
if let Some(c) = self.chars().next() {
s.push(c.to_uppercase().next().unwrap());
}
for c in self.chars().skip(1).into_iter() {
for c in self.chars().skip(1) {
if c.is_uppercase() {
s.push('_');
s.push(c)
Expand Down

0 comments on commit a3a3a42

Please sign in to comment.