Remove unused macros

This commit is contained in:
Tobie Morgan Hitchcock 2022-03-07 18:14:37 +00:00
parent 64c02896dd
commit 2a0d46a2b6
2 changed files with 8 additions and 30 deletions

View file

@ -1,29 +1,7 @@
macro_rules! output {
($expression:expr) => {
bytes::Bytes::from(format!("{}\n", $expression))
};
}
macro_rules! map { macro_rules! map {
($($k:expr => $v:expr),* $(,)?) => {{
let mut m = ::std::collections::BTreeMap::new();
$(m.insert($k, $v);)+
m
}};
}
macro_rules! hmap {
($($k:expr => $v:expr),* $(,)?) => {{ ($($k:expr => $v:expr),* $(,)?) => {{
let mut m = ::std::collections::HashMap::new(); let mut m = ::std::collections::HashMap::new();
$(m.insert($k, $v);)+ $(m.insert($k, $v);)+
m m
}}; }};
} }
macro_rules! bmap {
($($k:expr => $v:expr),* $(,)?) => {{
let mut m = ::std::collections::BTreeMap::new();
$(m.insert($k, $v);)+
m
}};
}

View file

@ -112,7 +112,7 @@ async fn select_all(
l = query.limit.unwrap_or_else(|| String::from("100")), l = query.limit.unwrap_or_else(|| String::from("100")),
s = query.start.unwrap_or_else(|| String::from("0")), s = query.start.unwrap_or_else(|| String::from("0")),
); );
let vars = hmap! { let vars = map! {
String::from("table") => Value::from(table), String::from("table") => Value::from(table),
}; };
match surrealdb::execute(db, sql.as_str(), session, Some(vars)).await { match surrealdb::execute(db, sql.as_str(), session, Some(vars)).await {
@ -137,7 +137,7 @@ async fn create_all(
match surrealdb::sql::json(data) { match surrealdb::sql::json(data) {
Ok(data) => { Ok(data) => {
let sql = "CREATE type::table($table) CONTENT $data"; let sql = "CREATE type::table($table) CONTENT $data";
let vars = hmap! { let vars = map! {
String::from("table") => Value::from(table), String::from("table") => Value::from(table),
String::from("data") => data, String::from("data") => data,
}; };
@ -162,7 +162,7 @@ async fn delete_all(
) -> Result<impl warp::Reply, warp::Rejection> { ) -> Result<impl warp::Reply, warp::Rejection> {
let db = DB.get().unwrap().clone(); let db = DB.get().unwrap().clone();
let sql = "DELETE type::table($table)"; let sql = "DELETE type::table($table)";
let vars = hmap! { let vars = map! {
String::from("table") => Value::from(table), String::from("table") => Value::from(table),
}; };
match surrealdb::execute(db, sql, session, Some(vars)).await { match surrealdb::execute(db, sql, session, Some(vars)).await {
@ -188,7 +188,7 @@ async fn select_one(
) -> Result<impl warp::Reply, warp::Rejection> { ) -> Result<impl warp::Reply, warp::Rejection> {
let db = DB.get().unwrap().clone(); let db = DB.get().unwrap().clone();
let sql = "SELECT * FROM type::thing($table, $id)"; let sql = "SELECT * FROM type::thing($table, $id)";
let vars = hmap! { let vars = map! {
String::from("table") => Value::from(table), String::from("table") => Value::from(table),
String::from("id") => Value::from(id), String::from("id") => Value::from(id),
}; };
@ -215,7 +215,7 @@ async fn create_one(
match surrealdb::sql::json(data) { match surrealdb::sql::json(data) {
Ok(data) => { Ok(data) => {
let sql = "CREATE type::thing($table, $id) CONTENT $data"; let sql = "CREATE type::thing($table, $id) CONTENT $data";
let vars = hmap! { let vars = map! {
String::from("table") => Value::from(table), String::from("table") => Value::from(table),
String::from("id") => Value::from(id), String::from("id") => Value::from(id),
String::from("data") => data, String::from("data") => data,
@ -246,7 +246,7 @@ async fn update_one(
match surrealdb::sql::json(data) { match surrealdb::sql::json(data) {
Ok(data) => { Ok(data) => {
let sql = "UPDATE type::thing($table, $id) CONTENT $data"; let sql = "UPDATE type::thing($table, $id) CONTENT $data";
let vars = hmap! { let vars = map! {
String::from("table") => Value::from(table), String::from("table") => Value::from(table),
String::from("id") => Value::from(id), String::from("id") => Value::from(id),
String::from("data") => data, String::from("data") => data,
@ -277,7 +277,7 @@ async fn modify_one(
match surrealdb::sql::json(data) { match surrealdb::sql::json(data) {
Ok(data) => { Ok(data) => {
let sql = "UPDATE type::thing($table, $id) MERGE $data"; let sql = "UPDATE type::thing($table, $id) MERGE $data";
let vars = hmap! { let vars = map! {
String::from("table") => Value::from(table), String::from("table") => Value::from(table),
String::from("id") => Value::from(id), String::from("id") => Value::from(id),
String::from("data") => data, String::from("data") => data,
@ -304,7 +304,7 @@ async fn delete_one(
) -> Result<impl warp::Reply, warp::Rejection> { ) -> Result<impl warp::Reply, warp::Rejection> {
let db = DB.get().unwrap().clone(); let db = DB.get().unwrap().clone();
let sql = "DELETE type::thing($table, $id)"; let sql = "DELETE type::thing($table, $id)";
let vars = hmap! { let vars = map! {
String::from("table") => Value::from(table), String::from("table") => Value::from(table),
String::from("id") => Value::from(id), String::from("id") => Value::from(id),
}; };