Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to write wrapper for try_get? QueryIdx is private #258

Open
Christoph-AK opened this issue Nov 15, 2022 · 0 comments
Open

How to write wrapper for try_get? QueryIdx is private #258

Christoph-AK opened this issue Nov 15, 2022 · 0 comments

Comments

@Christoph-AK
Copy link

Christoph-AK commented Nov 15, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant