Skip to content

Commit 1f91c48

Browse files
committed
move is_upper_snake_case to stdx
1 parent 5b2a2bc commit 1f91c48

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

crates/ide-db/src/imports/merge_imports.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::iter::empty;
44

55
use itertools::{EitherOrBoth, Itertools};
66
use parser::T;
7+
use stdx::is_upper_snake_case;
78
use syntax::{
89
algo,
910
ast::{self, make, AstNode, HasAttrs, HasName, HasVisibility, PathSegmentKind},
@@ -340,9 +341,6 @@ fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering {
340341
// snake_case < CamelCase < UPPER_SNAKE_CASE
341342
let a_text = a_name.as_str();
342343
let b_text = b_name.as_str();
343-
fn is_upper_snake_case(s: &str) -> bool {
344-
s.chars().all(|c| c.is_uppercase() || c == '_' || c.is_numeric())
345-
}
346344
if a_text.starts_with(char::is_lowercase)
347345
&& b_text.starts_with(char::is_uppercase)
348346
{

crates/stdx/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ pub fn char_has_case(c: char) -> bool {
171171
c.is_lowercase() || c.is_uppercase()
172172
}
173173

174+
pub fn is_upper_snake_case(s: &str) -> bool {
175+
s.chars().all(|c| c.is_uppercase() || c == '_' || c.is_numeric())
176+
}
177+
174178
pub fn replace(buf: &mut String, from: char, to: &str) {
175179
if !buf.contains(from) {
176180
return;

0 commit comments

Comments
 (0)