I'm querying a database and putting the results into a struct.
let mut stmt = conn.prepare("SELECT operator, site, starttime, endtime......");
let rows = stmt.query_map([], |row| {
Ok(ti_data {
operator: row.get(0)?,
site: row.get(1)?,
starttime: row.get(2)?,
endtime: row.get(3)?,
//more data here
})
};
Some values will be null and I can't change that since the data is created elsewhere and the code will panic if I try to use elements with null values. How can I replace null with 0 or ""?
I'm new to Rust and used to be checking values myself in C/C++/C#.
I would like to have something like
if (row.get(i).? == None) {
return 0;
}