Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Filter by
Sorted by
Tagged with
Filter by Employee ID
Score of 0
1 answer
204 views

I am writing a small cli application to learn rust and did start my error propagation with a lot of Result<_, Box<dyn std::error::Error>>. This is quite flexible and works nicely. Now I ...
Score of 0
1 answer
178 views

Let's say I call a function that returns me Result<Foo, Error1> and want to return Result<Foo, Error2>. Error2 implements From<Error1>. The two options I have in mind are fn f1() -&...
Score of 0
1 answer
120 views

Result<T, E>.as_ref() will convert it to Result<&T, &E>, but the expected result is Result<&T, E>.
Score of 0
1 answer
1800 views

I'm working JWT's in Rust and have come across a situation that I'm having some issues navigating. I'm new to both Rust and JWT's, so bare with me. I'm using the jwt crate found here. What I want to ...
Score of 1
2 answers
2782 views

I am reading Rust by Example book. In this example removing return in Err(e) => return Err(e) causes an error: expected `i32`, found enum `Result`` . Why is that? What is the difference between Err(...
Score of 0
1 answer
475 views

I'd like to take SomeType out of Result<Vec<Data<&SomeType>>>, and then pass it by a channel, but I failed: pub fn read(result: Result<Vec<Data<&SomeType>>, ()&...
Score of 4
1 answer
5173 views

I am trying to generify a Result that is returned by the reqwest::blocking::get function. It returns a Result<reqwest::blocking::Response, reqwest::Error> but the function it is called in ...
Score of 14
1 answer
7608 views

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 ...
Score of 1
2 answers
1309 views

I want to write something like this, but it won't compile due to a mismatch between types: fn main() -> std::result::Result<(), Box<dyn std::error::Error>> { let val = std::env::...
Score of 1
0 answers
64 views

How can I return my own string errors in rust? fn main() -> std::io::Result<(), std::io::Error> { let a = 30; if a == 10 { println!("ten"); } else if a == 20 { ...
Score of 2
1 answer
2045 views

I have the code below fn main() { let num: i64 = 600851475143; println!("Largest prime: {}", largest_prime_factor(num)); } fn largest_prime_factor(num:i64) -> Result<i64, ...
Score of 10
1 answer
6156 views

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 want ...
Score of 4
1 answer
919 views

I'm trying to make my own custom errors but I do not want Rust to automatically add Error: in front of the error messages. use std::error::Error; use std::fmt; #[derive(Debug)] enum CustomError { ...
Score of 7
1 answer
10782 views

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(); ...
Score of 13
1 answer
4166 views

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(); ...

15 30 50 per page