From a6a306502ef0d0f053b24bd013f4c00a13f88cb6 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 24 May 2020 06:20:30 +0900 Subject: [PATCH] Deny warnings for doc tests --- src/buf/ext/mod.rs | 6 +++--- src/buf/ext/reader.rs | 2 +- src/buf/ext/take.rs | 6 +++--- src/buf/ext/writer.rs | 2 +- src/buf/iter.rs | 5 +++-- src/lib.rs | 4 ++++ 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/buf/ext/mod.rs b/src/buf/ext/mod.rs index 7d6181438..4a292676a 100644 --- a/src/buf/ext/mod.rs +++ b/src/buf/ext/mod.rs @@ -27,7 +27,7 @@ pub trait BufExt: Buf { /// # Examples /// /// ``` - /// use bytes::{Buf, BufMut, buf::BufExt}; + /// use bytes::{BufMut, buf::BufExt}; /// /// let mut buf = b"hello world"[..].take(5); /// let mut dst = vec![]; @@ -79,7 +79,7 @@ pub trait BufExt: Buf { /// # Examples /// /// ``` - /// use bytes::{Buf, Bytes, buf::BufExt}; + /// use bytes::{Bytes, buf::BufExt}; /// use std::io::Read; /// /// let buf = Bytes::from("hello world"); @@ -135,7 +135,7 @@ pub trait BufMutExt: BufMut { /// # Examples /// /// ``` - /// use bytes::{BufMut, buf::BufMutExt}; + /// use bytes::buf::BufMutExt; /// use std::io::Write; /// /// let mut buf = vec![].writer(); diff --git a/src/buf/ext/reader.rs b/src/buf/ext/reader.rs index bc171add1..dde3548bf 100644 --- a/src/buf/ext/reader.rs +++ b/src/buf/ext/reader.rs @@ -26,7 +26,7 @@ impl Reader { /// ```rust /// use bytes::buf::BufExt; /// - /// let mut buf = b"hello world".reader(); + /// let buf = b"hello world".reader(); /// /// assert_eq!(b"hello world", buf.get_ref()); /// ``` diff --git a/src/buf/ext/take.rs b/src/buf/ext/take.rs index 5a98f6ba6..1d84868bf 100644 --- a/src/buf/ext/take.rs +++ b/src/buf/ext/take.rs @@ -22,7 +22,7 @@ impl Take { /// # Examples /// /// ```rust - /// use bytes::buf::{Buf, BufMut, BufExt}; + /// use bytes::buf::{BufMut, BufExt}; /// /// let mut buf = b"hello world".take(2); /// let mut dst = vec![]; @@ -49,7 +49,7 @@ impl Take { /// ```rust /// use bytes::{Buf, buf::BufExt}; /// - /// let mut buf = b"hello world".take(2); + /// let buf = b"hello world".take(2); /// /// assert_eq!(11, buf.get_ref().remaining()); /// ``` @@ -110,7 +110,7 @@ impl Take { /// # Examples /// /// ```rust - /// use bytes::{Buf, BufMut, buf::BufExt}; + /// use bytes::{BufMut, buf::BufExt}; /// /// let mut buf = b"hello world".take(2); /// let mut dst = vec![]; diff --git a/src/buf/ext/writer.rs b/src/buf/ext/writer.rs index 1418418e8..a14197c81 100644 --- a/src/buf/ext/writer.rs +++ b/src/buf/ext/writer.rs @@ -26,7 +26,7 @@ impl Writer { /// ```rust /// use bytes::buf::BufMutExt; /// - /// let mut buf = Vec::with_capacity(1024).writer(); + /// let buf = Vec::with_capacity(1024).writer(); /// /// assert_eq!(1024, buf.get_ref().capacity()); /// ``` diff --git a/src/buf/iter.rs b/src/buf/iter.rs index 5a3f26a2e..0f9bdc04f 100644 --- a/src/buf/iter.rs +++ b/src/buf/iter.rs @@ -9,7 +9,7 @@ use crate::Buf; /// Basic usage: /// /// ``` -/// use bytes::{Buf, Bytes}; +/// use bytes::Bytes; /// /// let buf = Bytes::from(&b"abc"[..]); /// let mut iter = buf.into_iter(); @@ -33,7 +33,7 @@ impl IntoIter { /// # Examples /// /// ``` - /// use bytes::{Buf, Bytes}; + /// use bytes::Bytes; /// use bytes::buf::IntoIter; /// /// let buf = Bytes::from_static(b"abc"); @@ -47,6 +47,7 @@ impl IntoIter { pub fn new(inner: T) -> IntoIter { IntoIter { inner } } + /// Consumes this `IntoIter`, returning the underlying value. /// /// # Examples diff --git a/src/lib.rs b/src/lib.rs index 3cc1fd711..aad09d42d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,10 @@ missing_debug_implementations, rust_2018_idioms )] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] #![doc(html_root_url = "https://docs.rs/bytes/0.5.4")] #![no_std]