Skip to content

Implement Debug trait for public structs #73

Closed
@zeodtr

Description

@zeodtr

It's useful to implement Debug trait for public structs.

The Rust document strongly recommends it: https://doc.rust-lang.org/std/fmt/index.html#fmtdisplay-vs-fmtdebug
Also, I found that there is a lint directive for it: https://doc.rust-lang.org/stable/nightly-rustc/rustc_lint/builtin/static.MISSING_DEBUG_IMPLEMENTATIONS.html
Maybe it would be nice to include that lint directive as deny to lib.rs.

Also, can traits like Catalog be modified to be dependent upon Debug trait like this?

pub trait Catalog: Debug {

It would be convenient when including a Box dyned trait member to a struct that wants to implement Debug trait. Otherwise, since Debug trait is not an auto trait, we must create a new wrapper trait only to specify Debug trait dependency.

Also, (maybe this is somewhat irrelevant to this issue. If so, ignore this) it would be convenient if Catalog trait be modified to be dependent also upon Send and Sync like this:

pub trait Catalog: Debug + Send + Sync {

Since Catalog trait is an async trait, adding Send and Sync can be useful. (BTW, I've added them to a trait that wraps the Catalog trait to include Debug trait.)

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions