-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement order strategy "alphabetical"
- Loading branch information
Showing
4 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod sort_decl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::cmp::Ordering; | ||
|
||
pub fn compare_in_alphabetical(a: &str, b: &str) -> Ordering { | ||
strip_vendor_prefix(a).cmp(strip_vendor_prefix(b)) | ||
} | ||
|
||
pub fn strip_vendor_prefix(s: &str) -> &str { | ||
s.strip_prefix('-') | ||
.and_then(|s| { | ||
let trimmed = s.trim_start_matches(|c: char| c.is_ascii_alphanumeric()); | ||
if s == trimmed { | ||
None | ||
} else { | ||
Some(trimmed) | ||
} | ||
}) | ||
.and_then(|s| s.strip_prefix('-')) | ||
.unwrap_or(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ pub mod config; | |
mod ctx; | ||
mod doc_gen; | ||
mod error; | ||
mod helpers; | ||
mod line_bounds; | ||
mod state; | ||
|
||
|