|
2 | 2 |
|
3 | 3 | #![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
|
4 | 4 |
|
| 5 | +use std::io as sio; |
5 | 6 | use std::process::Command;
|
6 | 7 | use std::{cmp::Ordering, ops, time::Instant};
|
7 |
| -use std::{io as sio, iter}; |
8 | 8 |
|
9 | 9 | mod macros;
|
10 | 10 | pub mod hash;
|
@@ -39,15 +39,19 @@ Uncomment `default = [ "backtrace" ]` in `crates/stdx/Cargo.toml`.
|
39 | 39 | }
|
40 | 40 |
|
41 | 41 | pub fn to_lower_snake_case(s: &str) -> String {
|
42 |
| - to_snake_case(s, char::to_ascii_lowercase) |
| 42 | + to_snake_case(s, char::to_lowercase) |
43 | 43 | }
|
44 | 44 | pub fn to_upper_snake_case(s: &str) -> String {
|
45 |
| - to_snake_case(s, char::to_ascii_uppercase) |
| 45 | + to_snake_case(s, char::to_uppercase) |
46 | 46 | }
|
47 | 47 |
|
48 | 48 | // Code partially taken from rust/compiler/rustc_lint/src/nonstandard_style.rs
|
49 | 49 | // commit: 9626f2b
|
50 |
| -fn to_snake_case<F: Fn(&char) -> char>(mut s: &str, change_case: F) -> String { |
| 50 | +fn to_snake_case<F, I>(mut s: &str, change_case: F) -> String |
| 51 | +where |
| 52 | + F: Fn(char) -> I, |
| 53 | + I: Iterator<Item = char>, |
| 54 | +{ |
51 | 55 | let mut words = vec![];
|
52 | 56 |
|
53 | 57 | // Preserve leading underscores
|
@@ -75,7 +79,7 @@ fn to_snake_case<F: Fn(&char) -> char>(mut s: &str, change_case: F) -> String {
|
75 | 79 | }
|
76 | 80 |
|
77 | 81 | last_upper = ch.is_uppercase();
|
78 |
| - buf.extend(iter::once(change_case(&ch))); |
| 82 | + buf.extend(change_case(ch)); |
79 | 83 | }
|
80 | 84 |
|
81 | 85 | words.push(buf);
|
|
0 commit comments