mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-16 00:00:15 +02:00
Update Bytes to Rust 2018 (#274)
This commit is contained in:
+2
-2
@@ -916,7 +916,7 @@ pub trait Buf {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Buf + ?Sized> Buf for &'a mut T {
|
||||
impl<T: Buf + ?Sized> Buf for &mut T {
|
||||
fn remaining(&self) -> usize {
|
||||
(**self).remaining()
|
||||
}
|
||||
@@ -952,7 +952,7 @@ impl<T: Buf + ?Sized> Buf for Box<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Buf for &'a [u8] {
|
||||
impl Buf for &[u8] {
|
||||
#[inline]
|
||||
fn remaining(&self) -> usize {
|
||||
self.len()
|
||||
|
||||
+3
-3
@@ -979,7 +979,7 @@ pub trait BufMut {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: BufMut + ?Sized> BufMut for &'a mut T {
|
||||
impl<T: BufMut + ?Sized> BufMut for &mut T {
|
||||
fn remaining_mut(&self) -> usize {
|
||||
(**self).remaining_mut()
|
||||
}
|
||||
@@ -1015,7 +1015,7 @@ impl<T: BufMut + ?Sized> BufMut for Box<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> BufMut for &'a mut [u8] {
|
||||
impl BufMut for &mut [u8] {
|
||||
#[inline]
|
||||
fn remaining_mut(&self) -> usize {
|
||||
self.len()
|
||||
@@ -1029,7 +1029,7 @@ impl<'a> BufMut for &'a mut [u8] {
|
||||
#[inline]
|
||||
unsafe fn advance_mut(&mut self, cnt: usize) {
|
||||
// Lifetime dance taken from `impl Write for &mut [u8]`.
|
||||
let (_, b) = ::std::mem::replace(self, &mut []).split_at_mut(cnt);
|
||||
let (_, b) = std::mem::replace(self, &mut []).split_at_mut(cnt);
|
||||
*self = b;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
use {Buf, BufMut};
|
||||
use buf::IntoIter;
|
||||
use crate::{Buf, BufMut};
|
||||
use crate::buf::IntoIter;
|
||||
use std::io::{IoSlice, IoSliceMut};
|
||||
|
||||
/// A `Chain` sequences two buffers.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
use {Buf, BufMut, IntoBuf, Bytes, BytesMut};
|
||||
use crate::{Buf, BufMut, IntoBuf, Bytes, BytesMut};
|
||||
|
||||
/// Conversion from a [`Buf`]
|
||||
///
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
use super::{Buf};
|
||||
use ::BytesMut;
|
||||
use crate::BytesMut;
|
||||
|
||||
/// Conversion into a `Buf`
|
||||
///
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
use Buf;
|
||||
use crate::Buf;
|
||||
|
||||
/// Iterator over the bytes contained by the buffer.
|
||||
///
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
use {Buf};
|
||||
use crate::{Buf};
|
||||
|
||||
use std::{cmp, io};
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
use {Buf};
|
||||
use crate::Buf;
|
||||
|
||||
use std::cmp;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
use BufMut;
|
||||
use crate::BufMut;
|
||||
|
||||
use std::{cmp, io};
|
||||
|
||||
|
||||
+18
-18
@@ -1,6 +1,6 @@
|
||||
use {Buf, BufMut, IntoBuf};
|
||||
use buf::IntoIter;
|
||||
use debug;
|
||||
use crate::{Buf, BufMut, IntoBuf};
|
||||
use crate::buf::IntoIter;
|
||||
use crate::debug;
|
||||
|
||||
use std::{cmp, fmt, mem, hash, slice, ptr, usize};
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
@@ -852,7 +852,7 @@ impl Bytes {
|
||||
/// assert_eq!(iter.next().map(|b| *b), Some(b'c'));
|
||||
/// assert_eq!(iter.next(), None);
|
||||
/// ```
|
||||
pub fn iter<'a>(&'a self) -> ::std::slice::Iter<'a, u8> {
|
||||
pub fn iter<'a>(&'a self) -> std::slice::Iter<'a, u8> {
|
||||
self.bytes().iter()
|
||||
}
|
||||
}
|
||||
@@ -997,7 +997,7 @@ impl Default for Bytes {
|
||||
}
|
||||
|
||||
impl fmt::Debug for Bytes {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Debug::fmt(&debug::BsDebug(&self.inner.as_ref()), fmt)
|
||||
}
|
||||
}
|
||||
@@ -1026,7 +1026,7 @@ impl IntoIterator for Bytes {
|
||||
|
||||
impl<'a> IntoIterator for &'a Bytes {
|
||||
type Item = &'a u8;
|
||||
type IntoIter = ::std::slice::Iter<'a, u8>;
|
||||
type IntoIter = std::slice::Iter<'a, u8>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.as_ref().into_iter()
|
||||
@@ -1534,7 +1534,7 @@ impl BytesMut {
|
||||
/// assert_eq!(iter.next().map(|b| *b), Some(b'c'));
|
||||
/// assert_eq!(iter.next(), None);
|
||||
/// ```
|
||||
pub fn iter<'a>(&'a self) -> ::std::slice::Iter<'a, u8> {
|
||||
pub fn iter<'a>(&'a self) -> std::slice::Iter<'a, u8> {
|
||||
self.bytes().iter()
|
||||
}
|
||||
}
|
||||
@@ -1725,7 +1725,7 @@ impl Default for BytesMut {
|
||||
}
|
||||
|
||||
impl fmt::Debug for BytesMut {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Debug::fmt(&debug::BsDebug(&self.inner.as_ref()), fmt)
|
||||
}
|
||||
}
|
||||
@@ -1761,7 +1761,7 @@ impl fmt::Write for BytesMut {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn write_fmt(&mut self, args: fmt::Arguments) -> fmt::Result {
|
||||
fn write_fmt(&mut self, args: fmt::Arguments<'_>) -> fmt::Result {
|
||||
fmt::write(self, args)
|
||||
}
|
||||
}
|
||||
@@ -1783,7 +1783,7 @@ impl IntoIterator for BytesMut {
|
||||
|
||||
impl<'a> IntoIterator for &'a BytesMut {
|
||||
type Item = &'a u8;
|
||||
type IntoIter = ::std::slice::Iter<'a, u8>;
|
||||
type IntoIter = std::slice::Iter<'a, u8>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.as_ref().into_iter()
|
||||
@@ -2818,25 +2818,25 @@ impl<'a, T: ?Sized> PartialOrd<&'a T> for BytesMut
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<BytesMut> for &'a [u8] {
|
||||
impl PartialEq<BytesMut> for &[u8] {
|
||||
fn eq(&self, other: &BytesMut) -> bool {
|
||||
*other == *self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialOrd<BytesMut> for &'a [u8] {
|
||||
impl PartialOrd<BytesMut> for &[u8] {
|
||||
fn partial_cmp(&self, other: &BytesMut) -> Option<cmp::Ordering> {
|
||||
other.partial_cmp(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<BytesMut> for &'a str {
|
||||
impl PartialEq<BytesMut> for &str {
|
||||
fn eq(&self, other: &BytesMut) -> bool {
|
||||
*other == *self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialOrd<BytesMut> for &'a str {
|
||||
impl PartialOrd<BytesMut> for &str {
|
||||
fn partial_cmp(&self, other: &BytesMut) -> Option<cmp::Ordering> {
|
||||
other.partial_cmp(self)
|
||||
}
|
||||
@@ -2938,25 +2938,25 @@ impl PartialOrd<Bytes> for String {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<Bytes> for &'a [u8] {
|
||||
impl PartialEq<Bytes> for &[u8] {
|
||||
fn eq(&self, other: &Bytes) -> bool {
|
||||
*other == *self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialOrd<Bytes> for &'a [u8] {
|
||||
impl PartialOrd<Bytes> for &[u8] {
|
||||
fn partial_cmp(&self, other: &Bytes) -> Option<cmp::Ordering> {
|
||||
other.partial_cmp(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialEq<Bytes> for &'a str {
|
||||
impl PartialEq<Bytes> for &str {
|
||||
fn eq(&self, other: &Bytes) -> bool {
|
||||
*other == *self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartialOrd<Bytes> for &'a str {
|
||||
impl PartialOrd<Bytes> for &str {
|
||||
fn partial_cmp(&self, other: &Bytes) -> Option<cmp::Ordering> {
|
||||
other.partial_cmp(self)
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ use std::fmt;
|
||||
/// `BsDebug` is not a part of public API of bytes crate.
|
||||
pub struct BsDebug<'a>(pub &'a [u8]);
|
||||
|
||||
impl<'a> fmt::Debug for BsDebug<'a> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
impl fmt::Debug for BsDebug<'_> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
write!(fmt, "b\"")?;
|
||||
for &c in self.0 {
|
||||
// https://doc.rust-lang.org/reference.html#byte-escapes
|
||||
|
||||
+3
-5
@@ -1,9 +1,7 @@
|
||||
extern crate either;
|
||||
use crate::{Buf, BufMut};
|
||||
|
||||
use {Buf, BufMut};
|
||||
|
||||
use self::either::Either;
|
||||
use self::either::Either::*;
|
||||
use either::Either;
|
||||
use either::Either::*;
|
||||
use std::io::{IoSlice, IoSliceMut};
|
||||
|
||||
impl<L, R> Buf for Either<L, R>
|
||||
|
||||
+3
-5
@@ -68,13 +68,11 @@
|
||||
//! perform a syscall, which has the potential of failing. Operations on `Buf`
|
||||
//! and `BufMut` are infallible.
|
||||
|
||||
#![deny(warnings, missing_docs, missing_debug_implementations)]
|
||||
#![deny(warnings, missing_docs, missing_debug_implementations, rust_2018_idioms)]
|
||||
#![doc(html_root_url = "https://docs.rs/bytes/0.5.0")]
|
||||
|
||||
extern crate byteorder;
|
||||
|
||||
pub mod buf;
|
||||
pub use buf::{
|
||||
pub use crate::buf::{
|
||||
Buf,
|
||||
BufMut,
|
||||
IntoBuf,
|
||||
@@ -82,7 +80,7 @@ pub use buf::{
|
||||
|
||||
mod bytes;
|
||||
mod debug;
|
||||
pub use bytes::{Bytes, BytesMut};
|
||||
pub use crate::bytes::{Bytes, BytesMut};
|
||||
|
||||
// Optional Serde support
|
||||
#[cfg(feature = "serde")]
|
||||
|
||||
+2
-4
@@ -1,7 +1,5 @@
|
||||
extern crate serde;
|
||||
|
||||
use std::{cmp, fmt};
|
||||
use self::serde::{Serialize, Serializer, Deserialize, Deserializer, de};
|
||||
use serde::{Serialize, Serializer, Deserialize, Deserializer, de};
|
||||
use super::{Bytes, BytesMut};
|
||||
|
||||
macro_rules! serde_impl {
|
||||
@@ -20,7 +18,7 @@ macro_rules! serde_impl {
|
||||
impl<'de> de::Visitor<'de> for $visitor_ty {
|
||||
type Value = $ty;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
formatter.write_str("byte array")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user