You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements Try)
--> src\main.rs:7:16
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot use the ? operator in a function that returns ()
... |
29 | | }
30 | | }
| |_- this function should return Result or Option to accept ?
|
= help: the trait Try is not implemented for ()
= note: required by from_error
error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements Try)
--> src\main.rs:13:16
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
13 | | let rows = conn.query(sql, &[&30])?;
| | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot use the ? operator in a function that returns ()
... |
29 | | }
30 | | }
| |_- this function should return Result or Option to accept ?
|
= help: the trait Try is not implemented for ()
= note: required by from_error
error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements Try)
--> src\main.rs:15:19
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
15 | | let row = row_result?;
| | ^^^^^^^^^^^ cannot use the ? operator in a function that returns ()
... |
29 | | }
30 | | }
| |_- this function should return Result or Option to accept ?
|
= help: the trait Try is not implemented for ()
= note: required by from_error
error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements Try)
--> src\main.rs:17:29
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
17 | | let ename: String = row.get(0)?;
| | ^^^^^^^^^^^ cannot use the ? operator in a function that returns ()
... |
29 | | }
30 | | }
| |_- this function should return Result or Option to accept ?
|
= help: the trait Try is not implemented for ()
= note: required by from_error
error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements Try)
--> src\main.rs:19:24
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
19 | | let sal: i32 = row.get("sal")?;
| | ^^^^^^^^^^^^^^^ cannot use the ? operator in a function that returns ()
... |
29 | | }
30 | | }
| |_- this function should return Result or Option to accept ?
|
= help: the trait Try is not implemented for ()
= note: required by from_error
error[E0277]: the ? operator can only be used in a function that returns Result or Option (or another type that implements Try)
--> src\main.rs:23:33
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
23 | | let comm: Option = row.get(2)?;
| | ^^^^^^^^^^^ cannot use the ? operator in a function that returns ()
... |
29 | | }
30 | | }
| |_- this function should return Result or Option to accept ?
|
= help: the trait Try is not implemented for ()
= note: required by from_error
error: aborting due to 6 previous errors; 1 warning emitted
I am using Rust 1.52.1
The text was updated successfully, but these errors were encountered:
I can't compile your example with these errors:
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsTry
)--> src\main.rs:7:16
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot use the
?
operator in a function that returns()
... |
29 | | }
30 | | }
| |_- this function should return
Result
orOption
to accept?
|
= help: the trait
Try
is not implemented for()
= note: required by
from_error
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsTry
)--> src\main.rs:13:16
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
13 | | let rows = conn.query(sql, &[&30])?;
| | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot use the
?
operator in a function that returns()
... |
29 | | }
30 | | }
| |_- this function should return
Result
orOption
to accept?
|
= help: the trait
Try
is not implemented for()
= note: required by
from_error
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsTry
)--> src\main.rs:15:19
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
15 | | let row = row_result?;
| | ^^^^^^^^^^^ cannot use the
?
operator in a function that returns()
... |
29 | | }
30 | | }
| |_- this function should return
Result
orOption
to accept?
|
= help: the trait
Try
is not implemented for()
= note: required by
from_error
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsTry
)--> src\main.rs:17:29
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
17 | | let ename: String = row.get(0)?;
| | ^^^^^^^^^^^ cannot use the
?
operator in a function that returns()
... |
29 | | }
30 | | }
| |_- this function should return
Result
orOption
to accept?
|
= help: the trait
Try
is not implemented for()
= note: required by
from_error
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsTry
)--> src\main.rs:19:24
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
19 | | let sal: i32 = row.get("sal")?;
| | ^^^^^^^^^^^^^^^ cannot use the
?
operator in a function that returns()
... |
29 | | }
30 | | }
| |_- this function should return
Result
orOption
to accept?
|
= help: the trait
Try
is not implemented for()
= note: required by
from_error
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsTry
)--> src\main.rs:23:33
|
4 | / fn main() {
5 | |
6 | | // Connect to a database.
7 | | let conn = Connection::connect("scott", "tiger", "//localhost/XE")?;
... |
23 | | let comm: Option = row.get(2)?;
| | ^^^^^^^^^^^ cannot use the
?
operator in a function that returns()
... |
29 | | }
30 | | }
| |_- this function should return
Result
orOption
to accept?
|
= help: the trait
Try
is not implemented for()
= note: required by
from_error
error: aborting due to 6 previous errors; 1 warning emitted
I am using Rust 1.52.1
The text was updated successfully, but these errors were encountered: