rust-result Questions
5
Solved
I have a function that returns a Result:
fn find(id: &Id) -> Result<Item, ItemError> {
// ...
}
Then another using it like this:
let parent_items: Vec<Item> = parent_ids.ite...
Accuracy asked 14/10, 2014 at 18:58
1
Solved
The canonical example of a Warp rejection handler is
async fn handle_rejection(err: Rejection) -> Result<impl Reply, Infallible> {
But what's the advantage of a Result<ok, err> such...
Top asked 4/6, 2021 at 2:19
1
Solved
I would like to write some code in a "functional programming" style.
However, I start with an Iterator of Results and I only want to apply the function to the Ok items. Furthermore, I wan...
Pinebrook asked 5/12, 2020 at 7:38
1
Solved
I cannot return a result of a function from a Result. Every tutorial only shows how to use a Result, but not how to return a value from it.
fn main(){
let mut a: Vec<String> = Vec::new();
a...
Kisor asked 30/6, 2020 at 10:41
1
Solved
I am using the Diesel ORM wrapper with PostgreSQL. I was following the guide on their website which has the following code:
pub fn establish_connection() -> PgConnection {
dotenv().ok();
let ...
Vachill asked 24/6, 2020 at 1:27
1
Solved
I was looking at the std::env::current_dir documentation and this caught my attention:
std::io::Result<()>
I thought a Result should have a T and an E. How can you substitute them with ()?
Kneeland asked 8/3, 2020 at 15:5
2
Solved
My first thought is to map the Option, but I can't use try! from inside of the closure. The match statement looks unnecessary, but I can't figure out how to simplify it.
fn example<T, E>(val...
Dasheen asked 2/4, 2017 at 8:45
4
Solved
I have code like this:
let things = vec![/* ...*/]; // e.g. Vec<String>
things
.map(|thing| {
let a = try!(do_stuff(thing));
Ok(other_stuff(a))
})
.filter(|thing_result| match *th...
Corneliuscornell asked 2/4, 2016 at 3:30
3
I'm using the regex crate to find some text with this regex:
lazy_static! {
static ref FIND_STEPS_RE: Regex =
Regex::new(r"my regex").unwrap();
}
I want to find all possible captures and itera...
Helminthiasis asked 15/11, 2017 at 21:39
2
Solved
In Rust, I believe the idiomatic way to deal with recoverable errors is to use Result. For example this function clearly is idiomatic:
fn do_work() -> Result<u64, WorkError> {...}
Of co...
Albric asked 27/4, 2016 at 0:14
1
© 2022 - 2024 — McMap. All rights reserved.