Skip to content

Commit c1013fa

Browse files
committed
refactor: remove the as_any() method from DictionaryBuilder trait
1 parent a348a10 commit c1013fa

File tree

4 files changed

+3
-13
lines changed

4 files changed

+3
-13
lines changed

src/dictionary/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ impl From<io::Error> for BuildDictionaryError {
433433
}
434434

435435
/// TODO: doc
436-
pub trait DictionaryBuilder {
436+
pub trait DictionaryBuilder: Any {
437437
/// TODO: doc
438438
fn set_info(&mut self, info: DictionaryInfo) -> Result<(), BuildDictionaryError>;
439439
/// TODO: doc
@@ -444,7 +444,6 @@ pub trait DictionaryBuilder {
444444
) -> Result<(), BuildDictionaryError>;
445445
/// TODO: doc
446446
fn build(&mut self, path: &Path) -> Result<(), BuildDictionaryError>;
447-
fn as_any(&self) -> &dyn Any;
448447
}
449448

450449
#[cfg(test)]

src/dictionary/sqlite.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::{
2-
any::Any,
32
error::Error,
43
fmt::Display,
54
path::{Path, PathBuf},
@@ -577,10 +576,6 @@ impl DictionaryBuilder for SqliteDictionaryBuilder {
577576
self.dict.conn.execute("VACUUM INTO ?", [path])?;
578577
Ok(())
579578
}
580-
581-
fn as_any(&self) -> &dyn Any {
582-
self
583-
}
584579
}
585580

586581
#[cfg(test)]

src/dictionary/trie.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::{
2-
any::Any,
32
cmp::Ordering,
43
collections::VecDeque,
54
error::Error,
@@ -1164,10 +1163,6 @@ impl DictionaryBuilder for TrieBuilder {
11641163
fs::rename(&tmpname, path)?;
11651164
Ok(())
11661165
}
1167-
1168-
fn as_any(&self) -> &dyn Any {
1169-
self
1170-
}
11711166
}
11721167

11731168
impl Default for TrieBuilder {

tools/src/init_database.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::{
2+
any::Any,
23
error::Error,
34
fmt::Display,
45
fs::{self, File},
@@ -156,7 +157,7 @@ pub(crate) fn run(args: flags::InitDatabase) -> Result<()> {
156157

157158
builder.build(path)?;
158159

159-
if let Some(trie_builder) = builder.as_any().downcast_ref::<TrieBuilder>() {
160+
if let Some(trie_builder) = (builder as Box<dyn Any>).downcast_ref::<TrieBuilder>() {
160161
let stats = trie_builder.statistics();
161162
eprintln!("== Trie Dictionary Statistics ==");
162163
eprintln!("Name : {}", info.name);

0 commit comments

Comments
 (0)