Skip to content

Commit a348a10

Browse files
committed
refactor: group imports
1 parent 4d209a5 commit a348a10

File tree

10 files changed

+35
-41
lines changed

10 files changed

+35
-41
lines changed

src/conversion/chewing.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use std::{
55

66
use tracing::trace;
77

8-
use super::{Composition, ConversionEngine, Gap, Interval, Symbol};
8+
use super::{Composition, ConversionEngine, Gap, Interval, Outcome, Symbol};
99
use crate::{
10-
conversion::Outcome,
1110
dictionary::{Dictionary, LookupStrategy, Phrase},
1211
zhuyin::Syllable,
1312
};

src/conversion/fuzzy.rs

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

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

src/conversion/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
//! Algorithms to convert syllables to Chinese characters.
22
3-
mod chewing;
4-
mod fuzzy;
5-
mod simple;
6-
mod symbol;
7-
83
use std::{
94
cmp::{max, min},
105
fmt::Debug,
@@ -16,6 +11,11 @@ pub use self::simple::SimpleEngine;
1611
pub(crate) use self::symbol::{full_width_symbol_input, special_symbol_input};
1712
use crate::{dictionary::Dictionary, zhuyin::Syllable};
1813

14+
mod chewing;
15+
mod fuzzy;
16+
mod simple;
17+
mod symbol;
18+
1919
/// Converts a composition buffer to list of intervals.
2020
///
2121
/// [`Composition`] contains all user inputs and selection information. The out

src/conversion/simple.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use super::{Composition, ConversionEngine, Interval};
21
use crate::{
3-
conversion::Outcome,
2+
conversion::{Composition, ConversionEngine, Interval, Outcome},
43
dictionary::{Dictionary, LookupStrategy},
54
};
65

src/dictionary/mod.rs

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

13-
pub use layered::Layered;
14-
pub use loader::{
13+
pub use self::layered::Layered;
14+
pub use self::loader::{
1515
DEFAULT_DICT_NAMES, LoadDictionaryError, SingleDictionaryLoader, SystemDictionaryLoader,
1616
UserDictionaryLoader,
1717
};
1818
#[cfg(feature = "sqlite")]
19-
pub use sqlite::{SqliteDictionary, SqliteDictionaryBuilder, SqliteDictionaryError};
20-
pub use trie::{Trie, TrieBuilder, TrieOpenOptions, TrieStatistics};
21-
pub use trie_buf::TrieBuf;
22-
19+
pub use self::sqlite::{SqliteDictionary, SqliteDictionaryBuilder, SqliteDictionaryError};
20+
pub use self::trie::{Trie, TrieBuilder, TrieOpenOptions, TrieStatistics};
21+
pub use self::trie_buf::TrieBuf;
2322
use crate::zhuyin::Syllable;
2423

2524
mod layered;

src/editor/mod.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
//! Abstract input method editors.
22
3-
mod abbrev;
4-
mod composition_editor;
5-
mod estimate;
6-
mod selection;
7-
pub mod zhuyin_layout;
8-
93
use std::{
104
any::Any,
115
cmp::{max, min},
@@ -14,9 +8,9 @@ use std::{
148
mem,
159
};
1610

17-
pub use estimate::{LaxUserFreqEstimate, UserFreqEstimate};
1811
use tracing::{debug, error, info, trace, warn};
1912

13+
pub use self::estimate::{LaxUserFreqEstimate, UserFreqEstimate};
2014
pub use self::{abbrev::AbbrevTable, selection::symbol::SymbolSelector};
2115
use self::{
2216
composition_editor::CompositionEditor,
@@ -36,6 +30,12 @@ use crate::{
3630
zhuyin::Syllable,
3731
};
3832

33+
mod abbrev;
34+
mod composition_editor;
35+
mod estimate;
36+
mod selection;
37+
pub mod zhuyin_layout;
38+
3939
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4040
pub enum LanguageMode {
4141
Chinese,
@@ -1545,14 +1545,13 @@ impl State for Highlighting {
15451545

15461546
#[cfg(test)]
15471547
mod tests {
1548-
use estimate::LaxUserFreqEstimate;
1549-
15501548
use super::collect_new_phrases;
1549+
use super::estimate::LaxUserFreqEstimate;
15511550
use super::{BasicEditor, Editor};
15521551
use crate::{
15531552
conversion::{ChewingEngine, Interval, Symbol},
15541553
dictionary::{Layered, TrieBuf},
1555-
editor::{EditorKeyBehavior, EditorOptions, SymbolSelector, abbrev::AbbrevTable, estimate},
1554+
editor::{EditorKeyBehavior, EditorOptions, SymbolSelector, abbrev::AbbrevTable},
15561555
input::{
15571556
KeyboardEvent, keycode,
15581557
keymap::{QWERTY_MAP, map_ascii},

src/input.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
33
use std::fmt::Display;
44

5-
use keycode::Keycode;
6-
use keysym::Keysym;
7-
8-
use crate::input::keysym::SYM_NONE;
5+
use self::keycode::Keycode;
6+
use self::keysym::{Keysym, SYM_NONE};
97

108
pub mod keycode;
119
pub mod keymap;

src/input/keymap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
//! It's recommended to use full featured library like xkbcommon to map keycode
99
//! to keysyms.
1010
11-
use crate::input::KeyState;
12-
use crate::input::KeyboardEvent;
13-
use crate::input::keycode::*;
14-
use crate::input::keysym::*;
11+
use super::KeyState;
12+
use super::KeyboardEvent;
13+
use super::keycode::*;
14+
use super::keysym::*;
1515

1616
macro_rules! keymap {
1717
($($k:expr => ($code:expr, $ksym:expr, $state:expr)),* $(,)?) => {{

src/zhuyin/bopomofo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub enum Bopomofo {
116116
TONE1,
117117
}
118118

119-
use Bopomofo::*;
119+
use self::Bopomofo::*;
120120

121121
const INITIAL_MAP: [Bopomofo; 21] = [
122122
B, P, M, F, D, T, N, L, G, K, H, J, Q, X, ZH, CH, SH, R, Z, C, S,

src/zhuyin/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Chinese syllables and bopomofo phonetic symbols.
22
3-
mod bopomofo;
4-
mod syllable;
5-
6-
pub use bopomofo::{Bopomofo, BopomofoErrorKind, BopomofoKind, ParseBopomofoError};
7-
pub use syllable::{
3+
pub use self::bopomofo::{Bopomofo, BopomofoErrorKind, BopomofoKind, ParseBopomofoError};
4+
pub use self::syllable::{
85
BuildSyllableError, DecodeSyllableError, ParseSyllableError, Syllable, SyllableBuilder,
96
SyllableErrorKind,
107
};
8+
9+
mod bopomofo;
10+
mod syllable;

0 commit comments

Comments
 (0)