Skip to content

Commit b80ecd6

Browse files
committed
Update to Rust edition 2021 and process new clippy warnings
1 parent d0c268a commit b80ecd6

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "xml-to-postgres"
33
version = "0.1.0"
44
authors = ["Bart Noordervliet <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66
description = "Fast converter from XML to PostgreSQL dump format"
77
publish = false
88

src/main.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'a> Table<'a> {
3535
}
3636
}
3737
fn write(&self, text: &str) {
38-
self.file.borrow_mut().write_all(&text.as_bytes()).expect("Write error encountered; exiting...");
38+
self.file.borrow_mut().write_all(text.as_bytes()).expect("Write error encountered; exiting...");
3939
}
4040
fn clear_columns(&self) {
4141
for col in &self.columns {
@@ -78,7 +78,7 @@ impl Geometry {
7878
}
7979
}
8080

81-
fn gml_to_ewkb(cell: &RefCell<String>, coll: &Vec<Geometry>) {
81+
fn gml_to_ewkb(cell: &RefCell<String>, coll: &[Geometry]) {
8282
let mut ewkb: Vec<u8> = vec![];
8383

8484
if coll.len() > 1 {
@@ -124,13 +124,10 @@ fn add_table<'a>(rowpath: &str, outfile: Option<&str>, filemode: &str, skip: Opt
124124
true => None,
125125
false => {
126126
let file = col["file"].as_str().expect("Subtable has no 'file' entry");
127-
Some(add_table(&path, Some(&file), filemode, skip, col["cols"].as_vec().expect("Subtable 'cols' entry is not an array")))
127+
Some(add_table(&path, Some(file), filemode, skip, col["cols"].as_vec().expect("Subtable 'cols' entry is not an array")))
128128
}
129129
};
130-
let filter: Option<Regex> = match col["filt"].as_str() {
131-
Some(str) => Some(Regex::new(&str).expect("Invalid regex in 'filt' entry in configuration file")),
132-
None => None
133-
};
130+
let filter: Option<Regex> = col["filt"].as_str().map(|str| Regex::new(str).expect("Invalid regex in 'filt' entry in configuration file"));
134131
let attr = col["attr"].as_str();
135132
let convert = col["conv"].as_str();
136133
let find = col["find"].as_str();
@@ -287,7 +284,7 @@ fn main() -> std::io::Result<()> {
287284
// Handle 'subtable' case (the 'cols' entry has 'cols' of its own)
288285
if table.columns[i].subtable.is_some() {
289286
tables.push(table);
290-
table = &table.columns[i].subtable.as_ref().unwrap();
287+
table = table.columns[i].subtable.as_ref().unwrap();
291288
break;
292289
}
293290

0 commit comments

Comments
 (0)