kubo / rust-oracle

Oracle driver for Rust
189 stars 44 forks source link

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

Closed ryvdx closed 1 year ago

ryvdx commented 1 year ago

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 commented 1 year ago

You need to learn error handling. Especially this section.

Examples use ? to follow this API guideline.