Skip to content

Commit ca02f58

Browse files
committed
tests/util/response: Implement Deref<Target=hyper::Response> for Response
This makes it possible to easily access e.g. `response.headers()`.
1 parent 1e66a57 commit ca02f58

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/tests/util/response.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use bytes::Bytes;
33
use googletest::prelude::*;
44
use serde_json::Value;
55
use std::marker::PhantomData;
6+
use std::ops::Deref;
67
use std::str::from_utf8;
78

89
use crates_io::rate_limiter::LimitedAction;
@@ -15,6 +16,14 @@ pub struct Response<T> {
1516
return_type: PhantomData<T>,
1617
}
1718

19+
impl Deref for Response<()> {
20+
type Target = hyper::Response<Bytes>;
21+
22+
fn deref(&self) -> &Self::Target {
23+
&self.response
24+
}
25+
}
26+
1827
impl<T> Response<T>
1928
where
2029
for<'de> T: serde::Deserialize<'de>,

0 commit comments

Comments
 (0)