Skip to content

Commit 56035f4

Browse files
committed
Fix warnings and formatting
1 parent f3e4bd8 commit 56035f4

5 files changed

Lines changed: 24 additions & 34 deletions

File tree

src/db.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ impl<'a> Iterator for MergedIterator<'a> {
6363
}
6464
}
6565

66-
if let Some(doc) = result {
67-
if !doc.is_null() {
68-
return Some((min_id, doc));
69-
}
70-
// If null (tombstone), loop again
66+
if let Some(doc) = result
67+
&& !doc.is_null()
68+
{
69+
return Some((min_id, doc));
7170
}
71+
// If null (tombstone), loop again
7272
}
7373
}
7474
}

src/jstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ mod tests {
220220
let file = NamedTempFile::new().unwrap();
221221
jstable.write(file.path().to_str().unwrap()).unwrap();
222222

223-
let mut iterator = JSTableIterator::new(file.path().to_str().unwrap())?;
223+
let iterator = JSTableIterator::new(file.path().to_str().unwrap())?;
224224
assert_eq!(iterator.timestamp, 12345);
225225

226226
let mut count = 0;

src/main.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ impl SimpleQueryHandler for ArgusHandler {
6060
Ok(s) => s,
6161
Err(e) => {
6262
return Ok(vec![Response::Error(Box::new(
63-
PgWireError::ApiError(Box::new(std::io::Error::new(
64-
std::io::ErrorKind::Other,
65-
e,
66-
)))
67-
.into(),
63+
PgWireError::ApiError(Box::new(std::io::Error::other(e))).into(),
6864
))]);
6965
}
7066
};
@@ -86,7 +82,7 @@ impl SimpleQueryHandler for ArgusHandler {
8682
)))])
8783
}
8884
Statement::Select(plan) => {
89-
let iter = execute_plan(plan, &*db);
85+
let iter = execute_plan(plan, &db);
9086

9187
let mut rows_data = Vec::new();
9288
for (_, doc) in iter {
@@ -103,9 +99,7 @@ impl SimpleQueryHandler for ArgusHandler {
10399
let obj = first.as_object().unwrap();
104100
let fields: Vec<FieldInfo> = obj
105101
.keys()
106-
.map(|k| {
107-
FieldInfo::new(k.clone().into(), None, None, Type::JSON, FieldFormat::Text)
108-
})
102+
.map(|k| FieldInfo::new(k.clone(), None, None, Type::JSON, FieldFormat::Text))
109103
.collect();
110104
let fields = Arc::new(fields);
111105

@@ -173,4 +167,4 @@ async fn main() {
173167
let _ = process_socket(socket, None, processor).await;
174168
});
175169
}
176-
}
170+
}

src/parser.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ struct ArgusDialect;
1111

1212
impl Dialect for ArgusDialect {
1313
fn is_identifier_start(&self, ch: char) -> bool {
14-
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_' || ch == '$'
14+
('a'..='z').contains(&ch) || ('A'..='Z').contains(&ch) || ch == '_' || ch == '$'
1515
}
1616

1717
fn is_identifier_part(&self, ch: char) -> bool {
18-
(ch >= 'a' && ch <= 'z')
19-
|| (ch >= 'A' && ch <= 'Z')
20-
|| (ch >= '0' && ch <= '9')
18+
('a'..='z').contains(&ch)
19+
|| ('A'..='Z').contains(&ch)
20+
|| ('0'..='9').contains(&ch)
2121
|| ch == '_'
2222
|| ch == '$'
2323
}
@@ -85,16 +85,13 @@ fn convert_query(query: &ast::Query) -> Result<LogicalPlan, String> {
8585
let mut offset_val = None;
8686

8787
if let Some(limit_clause) = &query.limit_clause {
88-
match limit_clause {
89-
LimitClause::LimitOffset { limit, offset, .. } => {
90-
if let Some(l) = limit {
91-
limit_val = Some(parse_limit_expr(l)?);
92-
}
93-
if let Some(o) = offset {
94-
offset_val = Some(parse_limit_expr(&o.value)?);
95-
}
88+
if let LimitClause::LimitOffset { limit, offset, .. } = limit_clause {
89+
if let Some(l) = limit {
90+
limit_val = Some(parse_limit_expr(l)?);
91+
}
92+
if let Some(o) = offset {
93+
offset_val = Some(parse_limit_expr(&o.value)?);
9694
}
97-
_ => {}
9895
}
9996
}
10097

@@ -266,7 +263,8 @@ mod tests {
266263

267264
#[test]
268265
fn test_parse_insert() {
269-
let sql = r#"INSERT INTO users VALUES (`{"name": "Alice", "age": 30}`), (`{"name": "Bob"}`)"#;
266+
let sql =
267+
r#"INSERT INTO users VALUES (`{"name": "Alice", "age": 30}`), (`{"name": "Bob"}`)"#;
270268
let stmt = parse(sql).unwrap();
271269
match stmt {
272270
Statement::Insert {

src/query.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'a> FilterOperator<'a> {
105105
impl<'a> Iterator for FilterOperator<'a> {
106106
type Item = (String, Value);
107107
fn next(&mut self) -> Option<Self::Item> {
108-
while let Some((id, doc)) = self.child.next() {
108+
for (id, doc) in self.child.by_ref() {
109109
if evaluate_expression(&self.predicate, &doc) == Value::Bool(true) {
110110
return Some((id, doc));
111111
}
@@ -203,9 +203,7 @@ impl<'a> Iterator for OffsetOperator<'a> {
203203
type Item = (String, Value);
204204
fn next(&mut self) -> Option<Self::Item> {
205205
while self.skipped < self.offset {
206-
if self.child.next().is_none() {
207-
return None;
208-
}
206+
self.child.next()?;
209207
self.skipped += 1;
210208
}
211209
self.child.next()

0 commit comments

Comments
 (0)