diff options
| author | davidsemakula <hello@davidsemakula.com> | 2024-01-16 13:37:22 +0300 |
|---|---|---|
| committer | davidsemakula <hello@davidsemakula.com> | 2024-01-16 13:37:22 +0300 |
| commit | 1f91c487a2d477b71beb3b61914f2782ba2ba169 (patch) | |
| tree | ca70c1c0fd72da7f26f37e3d2d4c55d11e91286f | |
| parent | 5b2a2bc3fb44912c4a7277d44aaf8ff8489324ef (diff) | |
| download | rust-1f91c487a2d477b71beb3b61914f2782ba2ba169.tar.gz rust-1f91c487a2d477b71beb3b61914f2782ba2ba169.zip | |
move is_upper_snake_case to stdx
| -rw-r--r-- | crates/ide-db/src/imports/merge_imports.rs | 4 | ||||
| -rw-r--r-- | crates/stdx/src/lib.rs | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/crates/ide-db/src/imports/merge_imports.rs b/crates/ide-db/src/imports/merge_imports.rs index 2aa26c2703d..740c50f79f1 100644 --- a/crates/ide-db/src/imports/merge_imports.rs +++ b/crates/ide-db/src/imports/merge_imports.rs @@ -4,6 +4,7 @@ use std::iter::empty; use itertools::{EitherOrBoth, Itertools}; use parser::T; +use stdx::is_upper_snake_case; use syntax::{ algo, ast::{self, make, AstNode, HasAttrs, HasName, HasVisibility, PathSegmentKind}, @@ -340,9 +341,6 @@ fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering { // snake_case < CamelCase < UPPER_SNAKE_CASE let a_text = a_name.as_str(); let b_text = b_name.as_str(); - fn is_upper_snake_case(s: &str) -> bool { - s.chars().all(|c| c.is_uppercase() || c == '_' || c.is_numeric()) - } if a_text.starts_with(char::is_lowercase) && b_text.starts_with(char::is_uppercase) { diff --git a/crates/stdx/src/lib.rs b/crates/stdx/src/lib.rs index 43909fff02c..cd5285295a2 100644 --- a/crates/stdx/src/lib.rs +++ b/crates/stdx/src/lib.rs @@ -171,6 +171,10 @@ pub fn char_has_case(c: char) -> bool { c.is_lowercase() || c.is_uppercase() } +pub fn is_upper_snake_case(s: &str) -> bool { + s.chars().all(|c| c.is_uppercase() || c == '_' || c.is_numeric()) +} + pub fn replace(buf: &mut String, from: char, to: &str) { if !buf.contains(from) { return; |
