From ebc95cb8f279ac286c40fc4821b8ce1900bbef5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 30 Jul 2019 15:15:47 +0200 Subject: [PATCH] feat: Display the documents fields in the order they were declared --- meilidb/Cargo.toml | 1 + meilidb/examples/query-database.rs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/meilidb/Cargo.toml b/meilidb/Cargo.toml index 7208067f0..0eecba0a1 100644 --- a/meilidb/Cargo.toml +++ b/meilidb/Cargo.toml @@ -14,6 +14,7 @@ csv = "1.0.7" diskus = "0.5.0" env_logger = "0.6.1" jemallocator = "0.1.9" +linked-hash-map = "0.5.2" meilidb-core = { path = "../meilidb-core", version = "0.1.0" } quickcheck = "0.8.2" rand = "0.6.5" diff --git a/meilidb/examples/query-database.rs b/meilidb/examples/query-database.rs index f9e2f8389..e6368727a 100644 --- a/meilidb/examples/query-database.rs +++ b/meilidb/examples/query-database.rs @@ -2,16 +2,17 @@ static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; use std::collections::btree_map::{BTreeMap, Entry}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; use std::error::Error; use std::io::{self, Write}; use std::iter::FromIterator; use std::path::PathBuf; use std::time::{Instant, Duration}; -use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; -use structopt::StructOpt; +use linked_hash_map::LinkedHashMap; use rustyline::{Editor, Config}; +use structopt::StructOpt; +use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use meilidb_core::Highlight; use meilidb_data::Database; @@ -35,7 +36,7 @@ pub struct Opt { pub char_context: usize, } -type Document = HashMap; +type Document = LinkedHashMap; fn display_highlights(text: &str, ranges: &[usize]) -> io::Result<()> { let mut stdout = StandardStream::stdout(ColorChoice::Always);