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

the ? operator can only be used in a function that returns Result or Option #72

Closed
ryvdx opened this issue Feb 16, 2023 · 1 comment
Closed

Comments

@ryvdx
Copy link

ryvdx commented Feb 16, 2023

Any help with this? Using your example, but getting a compile time errors. (copy/pasted your code)

"let row = row_result?;"
Produces a compile time error of:

the ? operator can only be used in a function that returns Result or Option (or another type that implements FromResidual)
the trait FromResidual<Result<Infallible, oracle::Error>> is not implemented for ()

Get that on each of the lines below on the ? character.

    // Run Oracle Query
    let rows = conn.query("SELECT myname, myvalue FROM marktest", &[&30])?;
    for row_result in rows {
        let row = row_result?;
        let myname: String = row.get(0)?;
        let myvalue: String = row.get(1)?;
        println!(" {:14}| {:>10}    ", myname, myvalue);
    }
@kubo
Copy link
Owner

kubo commented Feb 16, 2023

You need to learn error handling. Especially this section.

Examples use ? to follow this API guideline.

@kubo kubo closed this as completed Feb 16, 2023
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

2 participants