Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing lifetimes where it can be automatically inferred #160

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ jobs:
MYSQL_USER: njord_user
MYSQL_PASSWORD: njord_password
MYSQL_HOST: 127.0.0.1
run: cargo test --test sqlite_tests
run: cargo test --test mysql_tests
Binary file modified njord/db/insert.db
Binary file not shown.
8 changes: 4 additions & 4 deletions njord/src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ impl<'a, T: Table + Default> Column<'a, T> {
}
}

// Implement fmt::Display for Column
// Implementation of fmt::Display for Column
impl<'a, T: Table + Default> std::fmt::Display for Column<'a, T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.build())
}
}

// Implement PartialEq for Column
// Implementation of PartialEq for Column
impl<'a, T: Table + Default> PartialEq for Column<'a, T> {
fn eq(&self, other: &Self) -> bool {
self.build() == other.build()
}
}

// Implement PartialEq<String> for Column
// Implementation of PartialEq<String> for Column
impl<'a, T: Table + Default> PartialEq<String> for Column<'a, T> {
fn eq(&self, other: &String) -> bool {
match self {
Expand All @@ -42,7 +42,7 @@ impl<'a, T: Table + Default> PartialEq<String> for Column<'a, T> {
}
}

// You can also implement PartialEq<&str> for convenience
// Implementation of PartialEq<&str> for Column
impl<'a, T: Table + Default> PartialEq<&str> for Column<'a, T> {
fn eq(&self, other: &&str) -> bool {
match self {
Expand Down
2 changes: 1 addition & 1 deletion njord/src/mysql/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use crate::table::Table;
/// # Returns
///
/// A `DeleteQueryBuilder` instance.
pub fn delete<'a, T: Table + Default>(conn: &'a mut PooledConn) -> DeleteQueryBuilder<'a, T> {
pub fn delete<T: Table + Default>(conn: &mut PooledConn) -> DeleteQueryBuilder<T> {
DeleteQueryBuilder::new(conn)
}

Expand Down
4 changes: 2 additions & 2 deletions njord/src/mysql/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ use std::fmt::Error;
///
/// A `Result` containing a `String` representing the joined SQL statements
/// if the insertion is successful, or a `RusqliteError` if an error occurs.
pub fn insert<'a, T: Table>(
conn: &'a mut PooledConn,
pub fn insert<T: Table>(
conn: &mut PooledConn,
table_rows: Vec<T>,
) -> Result<String, RusqliteError> {
let mut statements: Vec<String> = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion njord/src/mysql/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use crate::util::{Join, JoinType};
/// # Returns
///
/// A `SelectQueryBuilder` instance.
pub fn select<'a, T: Table + Default>(columns: Vec<Column<'a, T>>) -> SelectQueryBuilder<'a, T> {
pub fn select<T: Table + Default>(columns: Vec<Column<T>>) -> SelectQueryBuilder<T> {
SelectQueryBuilder::new(columns)
}

Expand Down
6 changes: 3 additions & 3 deletions njord/src/mysql/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ use super::select::SelectQueryBuilder;
/// # Returns
///
/// An `UpdateQueryBuilder` instance.
pub fn update<'a, T: Table + Default>(
conn: &'a mut PooledConn,
pub fn update<T: Table + Default>(
conn: &mut PooledConn,
table: T,
) -> UpdateQueryBuilder<'a, T> {
) -> UpdateQueryBuilder<T> {
UpdateQueryBuilder::new(conn, table)
}

Expand Down
2 changes: 1 addition & 1 deletion njord/src/sqlite/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use crate::table::Table;
/// # Returns
///
/// A `DeleteQueryBuilder` instance.
pub fn delete<'a, T: Table + Default>(conn: &'a Connection) -> DeleteQueryBuilder<'a, T> {
pub fn delete<T: Table + Default>(conn: &Connection) -> DeleteQueryBuilder<T> {
DeleteQueryBuilder::new(conn)
}

Expand Down
4 changes: 2 additions & 2 deletions njord/src/sqlite/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ use std::fmt::Error;
///
/// A `Result` containing a `String` representing the joined SQL statements
/// if the insertion is successful, or a `RusqliteError` if an error occurs.
pub fn insert<'a, T: Table>(
conn: &'a Connection,
pub fn insert<T: Table>(
conn: &Connection,
table_rows: Vec<T>,
) -> Result<String, RusqliteError> {
let mut statements: Vec<String> = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion njord/src/sqlite/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use super::select::SelectQueryBuilder;
/// # Returns
///
/// An `UpdateQueryBuilder` instance.
pub fn update<'a, T: Table + Default>(conn: &'a Connection, table: T) -> UpdateQueryBuilder<'a, T> {
pub fn update<T: Table + Default>(conn: &Connection, table: T) -> UpdateQueryBuilder<T> {
UpdateQueryBuilder::new(conn, table)
}

Expand Down
Loading