Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
lovasoa committed Jan 10, 2025
1 parent 801b21c commit 0fbc719
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
10 changes: 5 additions & 5 deletions src/webserver/database/execute_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ fn vars_and_name<'a, 'b>(
}
}

async fn take_connection<'a, 'b>(
async fn take_connection<'a>(
db: &'a Database,
conn: &'b mut DbConn,
) -> anyhow::Result<&'b mut PoolConnection<sqlx::Any>> {
conn: &'a mut DbConn,
) -> anyhow::Result<&'a mut PoolConnection<sqlx::Any>> {
if let Some(c) = conn {
return Ok(c);
}
Expand Down Expand Up @@ -307,10 +307,10 @@ fn clone_anyhow_err(source_file: &Path, err: &anyhow::Error) -> anyhow::Error {
e
}

async fn bind_parameters<'a, 'b>(
async fn bind_parameters<'a>(
stmt: &'a StmtWithParams,
request: &'a RequestInfo,
db_connection: &'b mut DbConn,
db_connection: &mut DbConn,
) -> anyhow::Result<StatementWithParams<'a>> {
let sql = stmt.query.as_str();
log::debug!("Preparing statement: {}", sql);
Expand Down
2 changes: 1 addition & 1 deletion src/webserver/database/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn extract_toplevel_functions(stmt: &mut Statement) -> Vec<DelayedFunctionCall>
.enumerate()
.flat_map(|(position, item)| {
let mut items = Vec::with_capacity(1);
while it.peek().map_or(false, |x| x.position == position) {
while it.peek().is_some_and(|x| x.position == position) {
items.push(it.next().unwrap().expr_to_insert);
}
if items.is_empty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ macro_rules! sqlpage_functions {
}
}
impl SqlPageFunctionName {
pub(crate) async fn evaluate<'a, 'b>(
pub(crate) async fn evaluate<'a>(
&self,
#[allow(unused_variables)]
request: &'a RequestInfo,
db_connection: &'b mut Option<sqlx::pool::PoolConnection<sqlx::Any>>,
db_connection: &mut Option<sqlx::pool::PoolConnection<sqlx::Any>>,
params: Vec<Option<Cow<'a, str>>>
) -> anyhow::Result<Option<Cow<'a, str>>> {
use $crate::webserver::database::sqlpage_functions::function_traits::*;
Expand Down
5 changes: 1 addition & 4 deletions src/webserver/database/sqlpage_functions/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,7 @@ async fn test_random_string() {
assert_eq!(s.len(), 10);
}

async fn read_file_bytes<'a>(
request: &'a RequestInfo,
path_str: &str,
) -> Result<Vec<u8>, anyhow::Error> {
async fn read_file_bytes(request: &RequestInfo, path_str: &str) -> Result<Vec<u8>, anyhow::Error> {
let path = std::path::Path::new(path_str);
// If the path is relative, it's relative to the web root, not the current working directory,
// and it can be fetched from the on-database filesystem table
Expand Down
24 changes: 12 additions & 12 deletions src/webserver/database/syntax_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ impl SqlPageFunctionCall {
})
}

pub async fn evaluate<'a, 'b>(
pub async fn evaluate<'a>(
&self,
request: &'a RequestInfo,
db_connection: &'b mut DbConn,
db_connection: &mut DbConn,
) -> anyhow::Result<Option<Cow<'a, str>>> {
let mut params = Vec::with_capacity(self.arguments.len());
for param in &self.arguments {
Expand Down Expand Up @@ -149,10 +149,10 @@ impl std::fmt::Display for SqlPageFunctionCall {

/// Extracts the value of a parameter from the request.
/// Returns `Ok(None)` when NULL should be used as the parameter value.
pub(super) async fn extract_req_param<'a, 'b>(
pub(super) async fn extract_req_param<'a>(
param: &StmtParam,
request: &'a RequestInfo,
db_connection: &'b mut DbConn,
db_connection: &mut DbConn,
) -> anyhow::Result<Option<Cow<'a, str>>> {
Ok(match param {
// sync functions
Expand Down Expand Up @@ -181,10 +181,10 @@ pub(super) async fn extract_req_param<'a, 'b>(
})
}

async fn concat_params<'a, 'b>(
async fn concat_params<'a>(
args: &[StmtParam],
request: &'a RequestInfo,
db_connection: &'b mut DbConn,
db_connection: &mut DbConn,
) -> anyhow::Result<Option<Cow<'a, str>>> {
let mut result = String::new();
for arg in args {
Expand All @@ -196,10 +196,10 @@ async fn concat_params<'a, 'b>(
Ok(Some(Cow::Owned(result)))
}

async fn coalesce_params<'a, 'b>(
async fn coalesce_params<'a>(
args: &[StmtParam],
request: &'a RequestInfo,
db_connection: &'b mut DbConn,
db_connection: &mut DbConn,
) -> anyhow::Result<Option<Cow<'a, str>>> {
for arg in args {
if let Some(arg) = Box::pin(extract_req_param(arg, request, db_connection)).await? {
Expand All @@ -209,10 +209,10 @@ async fn coalesce_params<'a, 'b>(
Ok(None)
}

async fn json_object_params<'a, 'b>(
async fn json_object_params<'a>(
args: &[StmtParam],
request: &'a RequestInfo,
db_connection: &'b mut DbConn,
db_connection: &mut DbConn,
) -> anyhow::Result<Option<Cow<'a, str>>> {
use serde::{ser::SerializeMap, Serializer};
let mut result = Vec::new();
Expand Down Expand Up @@ -247,10 +247,10 @@ async fn json_object_params<'a, 'b>(
Ok(Some(Cow::Owned(String::from_utf8(result)?)))
}

async fn json_array_params<'a, 'b>(
async fn json_array_params<'a>(
args: &[StmtParam],
request: &'a RequestInfo,
db_connection: &'b mut DbConn,
db_connection: &mut DbConn,
) -> anyhow::Result<Option<Cow<'a, str>>> {
use serde::{ser::SerializeSeq, Serializer};
let mut result = Vec::new();
Expand Down

0 comments on commit 0fbc719

Please sign in to comment.