aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-02-20 23:22:00 +0000
committerFuwn <[email protected]>2021-02-20 23:22:00 +0000
commitb1b29f1b6c91879838c8b01c4f5a3c4b7a86ec77 (patch)
treebf5e932b2ee8e0899743b4963375156ca13ceff0 /src
parentchore, fix: refactor returns, grammar. (diff)
downloadchan-b1b29f1b6c91879838c8b01c4f5a3c4b7a86ec77.tar.xz
chan-b1b29f1b6c91879838c8b01c4f5a3c4b7a86ec77.zip
chore, fix, refactor: desc.
chore: - update readme fix: - grammer refactor: - undo previous commit return refactor
Diffstat (limited to 'src')
-rw-r--r--src/db.rs15
-rw-r--r--src/structures.rs4
2 files changed, 11 insertions, 8 deletions
diff --git a/src/db.rs b/src/db.rs
index f6d425e..11d35fb 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -28,13 +28,14 @@ pub fn _get_all_threads() -> Result<Vec<Thread>, SQLError> {
// Get all entries from the thread table.
let mut statement = db.prepare("SELECT board, name, comment FROM threads")?;
- statement.query_map(params![], |row| {
+ let threads = statement.query_map(params![], |row| {
Ok(Thread {
board: row.get(0)?,
name: row.get(1)?,
comment: row.get(2)?
})
- })?.collect()
+ })?;
+ threads.collect()
}
/// Get all boards from the SQLite database.
@@ -44,14 +45,15 @@ pub fn get_boards() -> Result<Vec<Board>, SQLError> {
// Get all entries from the thread table.
let mut statement = db.prepare("SELECT tag, name, nsfw, disabled FROM boards")?;
- statement.query_map(params![], |row| {
+ let boards = statement.query_map(params![], |row| {
Ok(Board {
tag: row.get(0)?,
name: row.get(1)?,
nsfw: row.get(2)?,
disabled: row.get(3)?
})
- })?.collect()
+ })?;
+ boards.collect()
}
/// Get all threads from a specific board within the SQLite database.
@@ -61,11 +63,12 @@ pub fn get_threads(board: String) -> Result<Vec<Thread>, SQLError> {
// Get all entries from the thread table.
let mut statement = db.prepare("SELECT board, name, comment FROM threads WHERE board = (?)")?;
- statement.query_map(params![board], |row| {
+ let threads = statement.query_map(params![board], |row| {
Ok(Thread {
board: row.get(0)?,
name: row.get(1)?,
comment: row.get(2)?
})
- })?.collect()
+ })?;
+ threads.collect()
}
diff --git a/src/structures.rs b/src/structures.rs
index 1114bbc..dceecd2 100644
--- a/src/structures.rs
+++ b/src/structures.rs
@@ -1,4 +1,4 @@
-/// The format a valid SQLlite thread entry should have.
+/// The format a valid SQLite thread entry should have.
#[derive(FromForm, Debug, Serialize, Deserialize)]
pub struct Thread {
pub board: String,
@@ -6,7 +6,7 @@ pub struct Thread {
pub comment: String
}
-/// The format a valid SQLlite thread entry should have.
+/// The format a valid SQLite thread entry should have.
#[derive(FromForm, Debug, Serialize, Deserialize, PartialEq)]
pub struct Board {
pub tag: String,