tiberius
tiberius copied to clipboard
How to write wrapper for try_get? QueryIdx is private
Hey there! Thanks so much for this awesome crate!
I want to write a custom wrapper for try_get, like this:
fn get_c_opt(r: &Row, id: impl QueryIdx) -> Result<Option<String>> {
Ok(r.try_get::<&str, _>(id)?.map(|s| s.to_string()))
}
fn get_c_or_empty(r: &Row, id: impl QueryIdx) -> Result<String> {
Ok(get_c_opt(r, id)?.unwrap_or_default())
}
But the QueryIdx trait is not exposed, so this doesn't compile. Is there any way to work around this, or could we expose the trait?