diff options
author | Teddy Wing | 2022-03-21 02:04:29 +0100 |
---|---|---|
committer | Teddy Wing | 2022-03-21 02:04:29 +0100 |
commit | 9816ad12c931e18ea7cc0e6cfaf3914a173e173e (patch) | |
tree | a03efc65717943382cbba21ae12e8161000eaba5 /src/sqlite.rs | |
parent | 3f5c588dcc24c2d8a642f56694f68b1afa2207ea (diff) | |
download | yaqlite-9816ad12c931e18ea7cc0e6cfaf3914a173e173e.tar.bz2 |
get_column_names(): Use `HashSet` instead of `HashMap`
This saves us from having to declare and use a vestigial unit struct
value for the hash.
In retrospect, I could have used the unit type instead of creating a
unit struct, but this is even cleaner. Only a couple hours ago learned
that `HashSet` exists.
Diffstat (limited to 'src/sqlite.rs')
-rw-r--r-- | src/sqlite.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/sqlite.rs b/src/sqlite.rs index c274b63..2185e66 100644 --- a/src/sqlite.rs +++ b/src/sqlite.rs @@ -1,18 +1,13 @@ use rusqlite; -use std::collections::HashMap; - - -#[derive(Debug)] -pub struct Zero; +use std::collections::HashSet; pub fn get_column_names( dbconn: &rusqlite::Connection, table_name: &str, -// TODO: Use a HashSet instead -) -> Result<HashMap<String, Zero>, crate::Error> { - let mut column_names = HashMap::new(); +) -> Result<HashSet<String>, crate::Error> { + let mut column_names = HashSet::new(); let mut stmt = dbconn.prepare( &format!( @@ -32,7 +27,7 @@ pub fn get_column_names( for row_result in rows { let row = row_result?; - column_names.insert(row, Zero{}); + column_names.insert(row); } Ok(column_names) |