Replies: 1 comment
-
You should probably use https://docs.rs/anyhow/latest/anyhow/ and change the signature of https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html has more info. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I tried to reaf a fgb file as ``` use flatgeobuf::*;
use std::fs::File;
use std::io::BufReader;
fn main() {
let mut filein = BufReader::new(File::open("countries.fgb")?);
let mut fgb = FgbReader::open(&mut filein)?.select_all()?;
while let Some(feature) = fgb.next()? {
println!("{}", feature.property::("name").unwrap());
println!("{}", feature.to_json()?);
}
}```. cargo build says:
Compiling geo1 v0.1.0 (/usr/local/geo1)
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsFromResidual
)--> src/main.rs:6:64
|
5 | fn main() {
| --------- this function should return
Result
orOption
to accept?
6 | let mut filein = BufReader::new(File::open("countries.fgb")?);
| ^ cannot use the
?
operator in a function that returns()
|
= help: the trait
FromResidual<Result<Infallible, std::io::Error>>
is not implemented for()
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsFromResidual
)--> src/main.rs:7:47
|
5 | fn main() {
| --------- this function should return
Result
orOption
to accept?
6 | let mut filein = BufReader::new(File::open("countries.fgb")?);
7 | let mut fgb = FgbReader::open(&mut filein)?.select_all()?;
| ^ cannot use the
?
operator in a function that returns()
|
= help: the trait
FromResidual<Result<Infallible, flatgeobuf::Error>>
is not implemented for()
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsFromResidual
)--> src/main.rs:7:61
|
5 | fn main() {
| --------- this function should return
Result
orOption
to accept?
6 | let mut filein = BufReader::new(File::open("countries.fgb")?);
7 | let mut fgb = FgbReader::open(&mut filein)?.select_all()?;
| ^ cannot use the
?
operator in a function that returns()
|
= help: the trait
FromResidual<Result<Infallible, flatgeobuf::Error>>
is not implemented for()
error[E0277]: the
?
operator can only be used in a function that returnsResult
orOption
(or another type that implementsFromResidual
)--> src/main.rs:8:41
|
5 | fn main() {
| --------- this function should return
Result
orOption
to accept?
...
8 | while let Some(feature) = fgb.next()? {
| ^ cannot use the
?
operator in a function that returns()
|
= help: the trait
FromResidual<Result<Infallible, flatgeobuf::Error>>
is not implemented for()
error[E0599]: no method named
to_json
found for reference&FgbFeature
in the current scope--> src/main.rs:10:32
|
10 | println!("{}", feature.to_json()?);
| ^^^^^^^ method not found in
&FgbFeature
Some errors have detailed explanations: E0277, E0599.
For more information about an error, try
rustc --explain E0277
.error: could not compile
geo1
(bin "geo1") due to 5 previous errors ```Beta Was this translation helpful? Give feedback.
All reactions