Skip to content

Commit

Permalink
Add debug impl for Publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
bitfl0wer committed Jul 13, 2024
1 parent 4ddcdbb commit 28cd5b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pubserve"
license = "MPL-2.0"
version = "1.0.0"
version = "1.1.0-alpha.1"
edition = "2021"
authors = ["bitfl0wer <[email protected]>"]
description = "Simple, generic observer trait."
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::fmt::Debug;
#[cfg(not(feature = "send"))]
use std::rc::Rc;
#[cfg(not(feature = "send"))]
Expand Down Expand Up @@ -59,6 +60,14 @@ pub struct Publisher<T> {
subscribers: Vec<ReferenceCounted<dyn Subscriber<T>>>,
}

impl<T> Debug for Publisher<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Publisher")
.field("subscribers", &self.subscribers.len())
.finish()
}
}

impl<T> std::default::Default for Publisher<T> {
fn default() -> Self {
Self {
Expand Down

0 comments on commit 28cd5b8

Please sign in to comment.