Skip to content

Commit

Permalink
Move the blanket impl outside of extension_trait.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Mar 11, 2022
1 parent 6b3667d commit c626a69
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/future/future/mod.rs
Expand Up @@ -285,3 +285,6 @@ extension_trait! {
}
}
}

impl<T: Future + ?Sized> FutureExt for T {}

2 changes: 2 additions & 0 deletions src/io/buf_read/mod.rs
Expand Up @@ -239,6 +239,8 @@ extension_trait! {
}
}

impl<T: BufRead + ?Sized> BufReadExt for T {}

pub fn read_until_internal<R: BufReadExt + ?Sized>(
mut reader: Pin<&mut R>,
cx: &mut Context<'_>,
Expand Down
3 changes: 2 additions & 1 deletion src/io/read/mod.rs
Expand Up @@ -372,10 +372,11 @@ extension_trait! {
fn chain<R: Read>(self, next: R) -> Chain<Self, R> where Self: Sized {
Chain { first: self, second: next, done_first: false }
}

}
}

impl<T: Read + ?Sized> ReadExt for T {}

/// Initializes a buffer if necessary.
///
/// Currently, a buffer is always initialized because `read_initializer`
Expand Down
2 changes: 2 additions & 0 deletions src/io/seek/mod.rs
Expand Up @@ -48,3 +48,5 @@ extension_trait! {
}
}
}

impl<T: Seek + ?Sized> SeekExt for T {}
2 changes: 2 additions & 0 deletions src/io/write/mod.rs
Expand Up @@ -185,3 +185,5 @@ extension_trait! {
}
}
}

impl<T: Write + ?Sized> WriteExt for T {}
3 changes: 3 additions & 0 deletions src/stream/stream/mod.rs
Expand Up @@ -2307,3 +2307,6 @@ extension_trait! {
}
}
}

impl<T: Stream + ?Sized> StreamExt for T {}

3 changes: 0 additions & 3 deletions src/utils.rs
Expand Up @@ -265,9 +265,6 @@ macro_rules! extension_trait {
pub trait $ext: $name {
extension_trait!(@ext [$($body_ext)*] -> []);
}

// Blanket implementation of the extension trait for any type implementing the base trait.
impl<T: $name + ?Sized> $ext for T {}
};

// Parse the return type in an extension method.
Expand Down

0 comments on commit c626a69

Please sign in to comment.