Use doc_cfg to show feature requirements (#1134)

* Use `doc_cfg` to show feature requirements

* Apply suggestions from code review
This commit is contained in:
nickelc
2021-02-18 01:48:08 +01:00
committed by GitHub
parent 727903f69a
commit c27cd06a11
10 changed files with 38 additions and 0 deletions

View File

@@ -136,6 +136,7 @@ impl Response {
///
/// This requires the optional `cookies` feature to be enabled.
#[cfg(feature = "cookies")]
#[cfg_attr(docsrs, doc(cfg(feature = "cookies")))]
pub fn cookies<'a>(&'a self) -> impl Iterator<Item = cookie::Cookie<'a>> + 'a {
cookie::extract_response_cookies(self.headers()).filter_map(Result::ok)
}
@@ -225,6 +226,7 @@ impl Response {
///
/// [`serde_json::from_reader`]: https://docs.serde.rs/serde_json/fn.from_reader.html
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn json<T: DeserializeOwned>(self) -> crate::Result<T> {
wait::timeout(self.inner.json(), self.timeout).map_err(|e| match e {
wait::Waited::TimedOut(e) => crate::error::decode(e),