diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-04 09:36:48 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-04 09:36:48 +0100 |
commit | 3b1d98308596e43299b1c7435a395b0a4d1db425 (patch) | |
tree | 0936853bbdc1cb70c469a9a00f71f003909789d2 /crates/stdx | |
parent | d85528081834639c4580fc135f74eb23447b12c7 (diff) | |
parent | 30817de3affd9376eed4ff164c42fe0e00a1ac37 (diff) |
Merge #4282
4282: More name hints omitting heuristics r=matklad a=SomeoneToIgnore
Omit parameter name hints for cases like the first two parameters from the screenshot:
<img width="394" alt="Screenshot 2020-05-03 at 15 06 34" src="https://user-images.githubusercontent.com/2690773/80914717-165b2f80-8d56-11ea-8675-040972f70d98.png">
Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/stdx')
-rw-r--r-- | crates/stdx/src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 01cdf452c..0f34ce70e 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs | |||
@@ -102,3 +102,17 @@ pub fn timeit(label: &'static str) -> impl Drop { | |||
102 | 102 | ||
103 | Guard { label, start: Instant::now() } | 103 | Guard { label, start: Instant::now() } |
104 | } | 104 | } |
105 | |||
106 | pub fn to_lower_snake_case(s: &str) -> String { | ||
107 | let mut buf = String::with_capacity(s.len()); | ||
108 | let mut prev = false; | ||
109 | for c in s.chars() { | ||
110 | if c.is_ascii_uppercase() && prev { | ||
111 | buf.push('_') | ||
112 | } | ||
113 | prev = true; | ||
114 | |||
115 | buf.push(c.to_ascii_lowercase()); | ||
116 | } | ||
117 | buf | ||
118 | } | ||