Skip to content

Commit 9bce35c

Browse files
committed
style: define rustfmt group_imports rule
1 parent 48b706c commit 9bce35c

File tree

31 files changed

+64
-101
lines changed

31 files changed

+64
-101
lines changed

capi/src/public.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ use std::{
44
iter::Peekable,
55
};
66

7-
use crate::logger::ExternLoggerFn;
87
use chewing::{
98
conversion::Interval,
109
dictionary::Entries,
1110
editor::{Editor, zhuyin_layout::KeyboardLayoutCompat},
1211
input::keymap::Keymap,
1312
};
1413

14+
use crate::logger::ExternLoggerFn;
15+
1516
/// Indicates chewing will translate keystrokes to Chinese characters.
1617
pub const CHINESE_MODE: c_int = 1;
1718
/// Indicates the input mode is translating keystrokes to symbols.

rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
group_imports = "StdExternalCrate"

src/conversion/chewing.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ use std::{
55

66
use tracing::trace;
77

8+
use super::{Composition, ConversionEngine, Gap, Interval, Symbol};
89
use crate::{
910
conversion::Outcome,
1011
dictionary::{Dictionary, LookupStrategy, Phrase},
1112
zhuyin::Syllable,
1213
};
1314

14-
use super::{Composition, ConversionEngine, Gap, Interval, Symbol};
15-
1615
/// The default Chewing conversion method.
1716
#[derive(Debug, Default)]
1817
pub struct ChewingEngine {
@@ -517,15 +516,14 @@ impl Display for PossiblePath {
517516
mod tests {
518517
use std::collections::HashSet;
519518

519+
use super::ChewingEngine;
520520
use crate::{
521521
conversion::{Composition, Gap, Interval, Outcome, Symbol, chewing::Edge},
522522
dictionary::{Dictionary, TrieBuf},
523523
syl,
524524
zhuyin::Bopomofo::*,
525525
};
526526

527-
use super::ChewingEngine;
528-
529527
fn test_dictionary() -> impl Dictionary {
530528
TrieBuf::from([
531529
(vec![syl![G, U, O, TONE2]], vec![("國", 1)]),

src/conversion/fuzzy.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use crate::{conversion::Outcome, dictionary::LookupStrategy};
2-
31
use super::{ChewingEngine, ConversionEngine};
2+
use crate::{conversion::Outcome, dictionary::LookupStrategy};
43

54
/// Same conversion method as Chewing but uses fuzzy phrase search.
65
#[derive(Debug, Default)]

src/conversion/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ use std::{
1010
fmt::Debug,
1111
};
1212

13-
use crate::{dictionary::Dictionary, zhuyin::Syllable};
14-
1513
pub use self::chewing::ChewingEngine;
1614
pub use self::fuzzy::FuzzyChewingEngine;
1715
pub use self::simple::SimpleEngine;
1816
pub(crate) use self::symbol::{full_width_symbol_input, special_symbol_input};
17+
use crate::{dictionary::Dictionary, zhuyin::Syllable};
1918

2019
/// Converts a composition buffer to list of intervals.
2120
///

src/conversion/simple.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
use super::{Composition, ConversionEngine, Interval};
12
use crate::{
23
conversion::Outcome,
34
dictionary::{Dictionary, LookupStrategy},
45
};
56

6-
use super::{Composition, ConversionEngine, Interval};
7-
87
/// Simple engine does not perform any intelligent conversion.
98
#[derive(Debug, Default)]
109
pub struct SimpleEngine;
@@ -65,15 +64,14 @@ impl ConversionEngine for SimpleEngine {
6564

6665
#[cfg(test)]
6766
mod tests {
67+
use super::SimpleEngine;
6868
use crate::{
6969
conversion::{Composition, Interval, Outcome, Symbol},
7070
dictionary::{Dictionary, TrieBuf},
7171
syl,
7272
zhuyin::Bopomofo::*,
7373
};
7474

75-
use super::SimpleEngine;
76-
7775
fn test_dictionary() -> impl Dictionary {
7876
TrieBuf::from([
7977
(vec![syl![G, U, O, TONE2]], vec![("國", 1)]),

src/dictionary/layered.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ use std::{
55

66
use tracing::error;
77

8-
use crate::zhuyin::Syllable;
9-
108
use super::{
119
Dictionary, DictionaryInfo, DictionaryMut, Entries, LookupStrategy, Phrase,
1210
UpdateDictionaryError,
1311
};
12+
use crate::zhuyin::Syllable;
1413

1514
/// A collection of dictionaries that returns the union of the lookup results.
1615
/// # Examples
@@ -220,6 +219,7 @@ mod tests {
220219
io::{Cursor, Seek},
221220
};
222221

222+
use super::Layered;
223223
use crate::{
224224
dictionary::{
225225
Dictionary, DictionaryBuilder, DictionaryMut, LookupStrategy, Phrase, Trie, TrieBuf,
@@ -229,8 +229,6 @@ mod tests {
229229
zhuyin::Bopomofo,
230230
};
231231

232-
use super::Layered;
233-
234232
#[test]
235233
fn test_entries() -> Result<(), Box<dyn Error>> {
236234
let sys_dict = TrieBuf::from([(

src/dictionary/loader.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ use std::{
99

1010
use tracing::{error, info};
1111

12+
#[cfg(feature = "sqlite")]
13+
use super::SqliteDictionary;
14+
use super::{Dictionary, TrieBuf, uhash};
1215
use crate::{
1316
editor::{AbbrevTable, SymbolSelector},
1417
path::{find_files_by_names, find_path_by_files, sys_path_from_env_var, userphrase_path},
1518
};
1619

17-
#[cfg(feature = "sqlite")]
18-
use super::SqliteDictionary;
19-
use super::{Dictionary, TrieBuf, uhash};
20-
2120
const UD_UHASH_FILE_NAME: &str = "uhash.dat";
2221
// const UD_TRIE_FILE_NAME: &str = "chewing.dat";
2322
const UD_SQLITE_FILE_NAME: &str = "chewing.sqlite3";

src/dictionary/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ use std::{
1010
path::Path,
1111
};
1212

13-
use crate::zhuyin::Syllable;
14-
1513
pub use layered::Layered;
1614
pub use loader::{
1715
DEFAULT_DICT_NAMES, LoadDictionaryError, SingleDictionaryLoader, SystemDictionaryLoader,
@@ -22,6 +20,8 @@ pub use sqlite::{SqliteDictionary, SqliteDictionaryBuilder, SqliteDictionaryErro
2220
pub use trie::{Trie, TrieBuilder, TrieOpenOptions, TrieStatistics};
2321
pub use trie_buf::TrieBuf;
2422

23+
use crate::zhuyin::Syllable;
24+
2525
mod layered;
2626
mod loader;
2727
#[cfg(feature = "sqlite")]

src/dictionary/sqlite.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ use std::{
88

99
use rusqlite::{Connection, Error as RusqliteError, OpenFlags, OptionalExtension, params};
1010

11-
use crate::zhuyin::Syllable;
12-
1311
use super::{
1412
BuildDictionaryError, Dictionary, DictionaryBuilder, DictionaryInfo, DictionaryMut, Entries,
1513
LookupStrategy, Phrase, UpdateDictionaryError,
1614
};
15+
use crate::zhuyin::Syllable;
1716

1817
const APPLICATION_ID: u32 = 0x43484557; // 'CHEW' in big-endian
1918
const USER_VERSION: u32 = 0;
@@ -592,6 +591,7 @@ mod tests {
592591
use rusqlite::{Connection, params};
593592
use tempfile::{NamedTempFile, tempdir};
594593

594+
use super::SqliteDictionary;
595595
use crate::{
596596
dictionary::{
597597
Dictionary, DictionaryBuilder, DictionaryMut, LookupStrategy, Phrase,
@@ -601,8 +601,6 @@ mod tests {
601601
zhuyin::Bopomofo,
602602
};
603603

604-
use super::SqliteDictionary;
605-
606604
#[test]
607605
fn migration_from_userphrase_v1() {
608606
let temp_path = NamedTempFile::new()

0 commit comments

Comments
 (0)