Skip to content

Commit a7e9af5

Browse files
committed
Update with associated type for FnMut
1 parent be6fbf6 commit a7e9af5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/lib.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ use std::old_io::net::ip::IpAddr;
99
pub use self::typemap::TypeMap;
1010
mod typemap;
1111

12-
#[derive(PartialEq, Show, Clone, Copy)]
12+
#[derive(PartialEq, Debug, Clone, Copy)]
1313
pub enum Scheme {
1414
Http,
1515
Https
1616
}
1717

18-
#[derive(PartialEq, Show, Clone, Copy)]
18+
#[derive(PartialEq, Debug, Clone, Copy)]
1919
pub enum Host<'a> {
2020
Name(&'a str),
2121
Ip(IpAddr)
2222
}
2323

24-
#[derive(PartialEq, Hash, Eq, Show, Clone, Copy)]
24+
#[derive(PartialEq, Hash, Eq, Debug, Clone, Copy)]
2525
pub enum Method {
2626
Get,
2727
Post,
@@ -115,14 +115,15 @@ pub struct Response {
115115

116116
/// A Handler takes a request and returns a response or an error.
117117
/// By default, a bare function implements `Handler`.
118-
pub trait Handler : Sync + Send {
118+
pub trait Handler: Sync + Send {
119119
fn call(&self, request: &mut Request) -> Result<Response, Box<Error+Send>>;
120120
}
121121

122-
impl<F> Handler for F
123-
where F: Fn(&mut Request) -> Result<Response, Box<Error+Send>> + Sync + Send,
122+
impl<F, E> Handler for F
123+
where F: Fn(&mut Request) -> Result<Response, E> + Sync + Send,
124+
E: Error + Send
124125
{
125126
fn call(&self, request: &mut Request) -> Result<Response, Box<Error+Send>> {
126-
(*self)(request)
127+
(*self)(request).map_err(|e| Box::new(e) as Box<Error+Send>)
127128
}
128129
}

0 commit comments

Comments
 (0)