mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
task: remove unnecessary trait bounds on the Debug implementation (#7720)
Remove the trait bounds of the `Debug` impl for `JoinQueue` and `AbortOnDropHandle`. Signed-off-by: ADD-SP <[email protected]>
This commit is contained in:
@@ -15,7 +15,6 @@ use std::{
|
|||||||
///
|
///
|
||||||
/// [aborts]: tokio::task::JoinHandle::abort
|
/// [aborts]: tokio::task::JoinHandle::abort
|
||||||
#[must_use = "Dropping the handle aborts the task immediately"]
|
#[must_use = "Dropping the handle aborts the task immediately"]
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct AbortOnDropHandle<T>(JoinHandle<T>);
|
pub struct AbortOnDropHandle<T>(JoinHandle<T>);
|
||||||
|
|
||||||
impl<T> Drop for AbortOnDropHandle<T> {
|
impl<T> Drop for AbortOnDropHandle<T> {
|
||||||
@@ -58,6 +57,14 @@ impl<T> AbortOnDropHandle<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> std::fmt::Debug for AbortOnDropHandle<T> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("AbortOnDropHandle")
|
||||||
|
.field("id", &self.0.id())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Future for AbortOnDropHandle<T> {
|
impl<T> Future for AbortOnDropHandle<T> {
|
||||||
type Output = Result<T, JoinError>;
|
type Output = Result<T, JoinError>;
|
||||||
|
|
||||||
@@ -71,3 +78,18 @@ impl<T> AsRef<JoinHandle<T>> for AbortOnDropHandle<T> {
|
|||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// A simple type that does not implement [`std::fmt::Debug`].
|
||||||
|
struct NotDebug;
|
||||||
|
|
||||||
|
fn is_debug<T: std::fmt::Debug>() {}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn assert_debug() {
|
||||||
|
is_debug::<AbortOnDropHandle<NotDebug>>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ use tokio::{
|
|||||||
///
|
///
|
||||||
/// When the [`JoinQueue`] is dropped, all tasks in the [`JoinQueue`] are
|
/// When the [`JoinQueue`] is dropped, all tasks in the [`JoinQueue`] are
|
||||||
/// immediately aborted.
|
/// immediately aborted.
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct JoinQueue<T>(VecDeque<AbortOnDropHandle<T>>);
|
pub struct JoinQueue<T>(VecDeque<AbortOnDropHandle<T>>);
|
||||||
|
|
||||||
impl<T> JoinQueue<T> {
|
impl<T> JoinQueue<T> {
|
||||||
@@ -379,6 +378,14 @@ impl<T> JoinQueue<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> std::fmt::Debug for JoinQueue<T> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_list()
|
||||||
|
.entries(self.0.iter().map(|jh| JoinHandle::id(jh.as_ref())))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> Default for JoinQueue<T> {
|
impl<T> Default for JoinQueue<T> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new()
|
||||||
@@ -401,3 +408,18 @@ where
|
|||||||
set
|
set
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// A simple type that does not implement [`std::fmt::Debug`].
|
||||||
|
struct NotDebug;
|
||||||
|
|
||||||
|
fn is_debug<T: std::fmt::Debug>() {}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn assert_debug() {
|
||||||
|
is_debug::<JoinQueue<NotDebug>>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user