chore: formatting

This commit is contained in:
Elias Renman
2023-05-07 11:19:22 +02:00
parent fe8437de6c
commit 8ea347bc98
7 changed files with 59 additions and 65 deletions

View File

@@ -1,4 +1,3 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
@@ -7,5 +6,4 @@ pub struct Index {
key: String, key: String,
asd_sort: bool, asd_sort: bool,
unique: bool, unique: bool,
} }

View File

@@ -63,7 +63,6 @@ mod tests {
panic!("Unable to find table"); panic!("Unable to find table");
} }
let row = table.unwrap().find_by_pk(&1u64); let row = table.unwrap().find_by_pk(&1u64);
assert_eq!(row.is_ok(), true); assert_eq!(row.is_ok(), true);

View File

@@ -1,14 +1,14 @@
use serde::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
use std::collections::HashMap; use std::collections::HashMap;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct Row { pub struct Row {
pub columns: HashMap<String, Value> pub columns: HashMap<String, Value>,
} }
impl Row { impl Row {
pub fn new(cols: HashMap<String, Value>) -> Row { pub fn new(cols: HashMap<String, Value>) -> Row {
Row {columns: cols} Row { columns: cols }
} }
} }

View File

@@ -1,8 +1,6 @@
use super::{index::Index, row::Row};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fs}; use std::{collections::HashMap, fs};
use super::{index::Index, row::Row};
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct Table { pub struct Table {
@@ -13,9 +11,13 @@ pub struct Table {
} }
impl Table { impl Table {
pub fn new(name: &str, pk_key: &str) -> Table { pub fn new(name: &str, pk_key: &str) -> Table {
Table { indexes: vec![], rows: HashMap::new(), name: name.to_string(), pk_key: pk_key.to_string() } Table {
indexes: vec![],
rows: HashMap::new(),
name: name.to_string(),
pk_key: pk_key.to_string(),
}
} }
pub fn create_index(&mut self, index: Index) { pub fn create_index(&mut self, index: Index) {
@@ -47,4 +49,3 @@ impl Table {
self.rows.insert(key.unwrap(), row); self.rows.insert(key.unwrap(), row);
} }
} }

View File

@@ -1,4 +1,3 @@
macro_rules! hashmapJson { macro_rules! hashmapJson {
($( $key: expr => $val: expr ),*) => {{ ($( $key: expr => $val: expr ),*) => {{
let mut map: ::std::collections::HashMap<String, ::serde_json::Value> = ::std::collections::HashMap::new(); let mut map: ::std::collections::HashMap<String, ::serde_json::Value> = ::std::collections::HashMap::new();
@@ -17,8 +16,7 @@ macro_rules! hashmap {
mod database; mod database;
fn main() { fn main() {}
}
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;

View File

@@ -1,7 +1,7 @@
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::database::{table::Table, row::Row}; use crate::database::{row::Row, table::Table};
#[test] #[test]
fn should_find_two_rows() { fn should_find_two_rows() {
@@ -29,6 +29,4 @@ mod tests {
let row = table.find_by_pk(&3u64); let row = table.find_by_pk(&3u64);
assert_eq!(row.is_err(), true); assert_eq!(row.is_err(), true);
} }
} }