Skip to content

Commit

Permalink
style: Run cargo fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecelis committed Apr 22, 2024
1 parent aabf0b3 commit 35eb638
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ mod trie {
.next()
.is_some();
for _ in 0..(times - 1) {
let _ = trie.common_prefix_search::<Vec<u8>, _>("すしをにぎる")
let _ = trie
.common_prefix_search::<Vec<u8>, _>("すしをにぎる")
.next()
.is_some();
}
Expand Down
4 changes: 2 additions & 2 deletions src/inc_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//!
//! ```rust
//! use trie_rs::Trie;
//!
//!
//! let q = "appli"; // query string
//! let mut is_match: bool;
//! let trie = Trie::from_iter(vec!["appli", "application"]);
Expand Down Expand Up @@ -122,7 +122,7 @@ impl<'a, Label: Ord, Value> IncSearch<'a, Label, Value> {
pub fn resume(trie: &'a Trie<Label, Value>, position: Position) -> Self {
Self {
trie,
node: position
node: position,
}
}

Expand Down
16 changes: 11 additions & 5 deletions src/trie/trie_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,26 +243,33 @@ mod search_tests {
let _ = trie.common_prefix_search::<String, _>("").next();
}


#[cfg(feature = "mem_dbg")]
#[test]
/// ```sh
/// cargo test --features mem_dbg memsize -- --nocapture
/// ```
fn memsize() {
use std::{env, io::{BufReader, BufRead}, fs::{File}};
use mem_dbg::*;
use std::{
env,
fs::File,
io::{BufRead, BufReader},
};

const COUNT: usize = 100;
let mut builder = TrieBuilder::new();

let repo_root = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR environment variable must be set.");
let repo_root = env::var("CARGO_MANIFEST_DIR")
.expect("CARGO_MANIFEST_DIR environment variable must be set.");
let edict2_path = format!("{}/benches/edict.furigana", repo_root);
println!("Reading dictionary file from: {}", edict2_path);

let mut n_words = 0;
let mut accum = 0;
for result in BufReader::new(File::open(edict2_path).unwrap()).lines().take(COUNT) {
for result in BufReader::new(File::open(edict2_path).unwrap())
.lines()
.take(COUNT)
{
let l = result.unwrap();
accum += l.len();
builder.push(l);
Expand All @@ -278,7 +285,6 @@ mod search_tests {
eprintln!("Uncompressed size {}", uncompressed_size);
assert!(accum < trie_size); // This seems wrong to me.
assert!(trie_size < uncompressed_size);

}

mod exact_match_tests {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ fn test_readme_deps() {
#[test]
fn test_html_root_url() {
version_sync::assert_html_root_url_updated!("src/lib.rs");
}
}

0 comments on commit 35eb638

Please sign in to comment.