mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
move is_upper_snake_case to stdx
This commit is contained in:
parent
5b2a2bc3fb
commit
1f91c487a2
2 changed files with 5 additions and 3 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue