aboutsummaryrefslogtreecommitdiff
path: root/src/buf/ext
diff options
context:
space:
mode:
Diffstat (limited to 'src/buf/ext')
-rw-r--r--src/buf/ext/chain.rs21
-rw-r--r--src/buf/ext/limit.rs5
-rw-r--r--src/buf/ext/mod.rs24
-rw-r--r--src/buf/ext/reader.rs2
-rw-r--r--src/buf/ext/take.rs5
5 files changed, 30 insertions, 27 deletions
diff --git a/src/buf/ext/chain.rs b/src/buf/ext/chain.rs
index a1ec597..e62e2f1 100644
--- a/src/buf/ext/chain.rs
+++ b/src/buf/ext/chain.rs
@@ -1,12 +1,12 @@
-use crate::{Buf, BufMut};
use crate::buf::IntoIter;
+use crate::{Buf, BufMut};
use core::mem::MaybeUninit;
#[cfg(feature = "std")]
-use std::io::{IoSlice};
-#[cfg(feature = "std")]
use crate::buf::IoSliceMut;
+#[cfg(feature = "std")]
+use std::io::IoSlice;
/// A `Chain` sequences two buffers.
///
@@ -41,10 +41,7 @@ pub struct Chain<T, U> {
impl<T, U> Chain<T, U> {
/// Creates a new `Chain` sequencing the provided values.
pub fn new(a: T, b: U) -> Chain<T, U> {
- Chain {
- a,
- b,
- }
+ Chain { a, b }
}
/// Gets a reference to the first underlying `Buf`.
@@ -137,8 +134,9 @@ impl<T, U> Chain<T, U> {
}
impl<T, U> Buf for Chain<T, U>
- where T: Buf,
- U: Buf,
+where
+ T: Buf,
+ U: Buf,
{
fn remaining(&self) -> usize {
self.a.remaining() + self.b.remaining()
@@ -179,8 +177,9 @@ impl<T, U> Buf for Chain<T, U>
}
impl<T, U> BufMut for Chain<T, U>
- where T: BufMut,
- U: BufMut,
+where
+ T: BufMut,
+ U: BufMut,
{
fn remaining_mut(&self) -> usize {
self.a.remaining_mut() + self.b.remaining_mut()
diff --git a/src/buf/ext/limit.rs b/src/buf/ext/limit.rs
index f86e011..a36ecee 100644
--- a/src/buf/ext/limit.rs
+++ b/src/buf/ext/limit.rs
@@ -11,10 +11,7 @@ pub struct Limit<T> {
}
pub(super) fn new<T>(inner: T, limit: usize) -> Limit<T> {
- Limit {
- inner,
- limit,
- }
+ Limit { inner, limit }
}
impl<T> Limit<T> {
diff --git a/src/buf/ext/mod.rs b/src/buf/ext/mod.rs
index 7b0bdab..7d61814 100644
--- a/src/buf/ext/mod.rs
+++ b/src/buf/ext/mod.rs
@@ -10,9 +10,9 @@ mod take;
#[cfg(feature = "std")]
mod writer;
+pub use self::chain::Chain;
pub use self::limit::Limit;
pub use self::take::Take;
-pub use self::chain::Chain;
#[cfg(feature = "std")]
pub use self::{reader::Reader, writer::Writer};
@@ -41,7 +41,8 @@ pub trait BufExt: Buf {
/// assert_eq!(dst, b" world");
/// ```
fn take(self, limit: usize) -> Take<Self>
- where Self: Sized
+ where
+ Self: Sized,
{
take::new(self, limit)
}
@@ -62,7 +63,8 @@ pub trait BufExt: Buf {
/// assert_eq!(full.bytes(), b"hello world");
/// ```
fn chain<U: Buf>(self, next: U) -> Chain<Self, U>
- where Self: Sized
+ where
+ Self: Sized,
{
Chain::new(self, next)
}
@@ -91,7 +93,10 @@ pub trait BufExt: Buf {
/// assert_eq!(&dst[..11], &b"hello world"[..]);
/// ```
#[cfg(feature = "std")]
- fn reader(self) -> Reader<Self> where Self: Sized {
+ fn reader(self) -> Reader<Self>
+ where
+ Self: Sized,
+ {
reader::new(self)
}
}
@@ -114,7 +119,8 @@ pub trait BufMutExt: BufMut {
/// assert_eq!(dst.remaining_mut(), 10);
/// ```
fn limit(self, limit: usize) -> Limit<Self>
- where Self: Sized
+ where
+ Self: Sized,
{
limit::new(self, limit)
}
@@ -142,7 +148,10 @@ pub trait BufMutExt: BufMut {
/// assert_eq!(*buf, b"hello world"[..]);
/// ```
#[cfg(feature = "std")]
- fn writer(self) -> Writer<Self> where Self: Sized {
+ fn writer(self) -> Writer<Self>
+ where
+ Self: Sized,
+ {
writer::new(self)
}
@@ -167,7 +176,8 @@ pub trait BufMutExt: BufMut {
/// assert_eq!(&b[..], b" world");
/// ```
fn chain_mut<U: BufMut>(self, next: U) -> Chain<Self, U>
- where Self: Sized
+ where
+ Self: Sized,
{
Chain::new(self, next)
}
diff --git a/src/buf/ext/reader.rs b/src/buf/ext/reader.rs
index e38103b..bc171ad 100644
--- a/src/buf/ext/reader.rs
+++ b/src/buf/ext/reader.rs
@@ -1,4 +1,4 @@
-use crate::{Buf};
+use crate::Buf;
use std::{cmp, io};
diff --git a/src/buf/ext/take.rs b/src/buf/ext/take.rs
index 6fc4ffc..6247165 100644
--- a/src/buf/ext/take.rs
+++ b/src/buf/ext/take.rs
@@ -13,10 +13,7 @@ pub struct Take<T> {
}
pub fn new<T>(inner: T, limit: usize) -> Take<T> {
- Take {
- inner,
- limit,
- }
+ Take { inner, limit }
}
impl<T> Take<T> {