notify-rs/notify

Debouncers don't implement Debug

awused opened this issue · 3 comments

awused commented

Thanks for maintaining this.

It's a minor thing but right now it's annoying to use the debouncers (either of them) as a drop-in replacements for watchers since they don't implement Debug.

0xpr03 commented

You mean adding Debug to the Debouncer, so you can print it like the Backends (like PollWatcher)?

Do you need any meaningful data from that debug print ? Or rather: What is your use case for debug-printing the debouncer / watcher ?

awused commented

It's not really about printing anything useful it's about not getting in the way of existing derive(Debug) implementations.

I can have this struct in my program:

#[derive(Debug)]
struct MyStructWithWatcher {
    map_of_something: HashMap<String, usize>,
    // Whatever other other program state is relevant

    watcher: RecommendedWatcher
}

But this similar struct will fail to compile.

#[derive(Debug)]
struct MyStructWithDebouncer {
    map_of_something: HashMap<String, usize>,
    // Whatever other other program state is relevant

    watcher: Debouncer<RecommendedWatcher>
}

If MyStruct is some existing struct where I wanted to replace a Watcher with a Debouncer I now need to work around this !Debug field with some kind of newtype wrapper or write my own debug implementation. In general all types in public APIs should derive Debug if only so they don't get in the way, there's also official rust api guidelines on this, though I don't know how many projects really bother to follow them all. https://github.com/rust-lang/api-guidelines/blob/master/src/debuggability.md

0xpr03 commented

I see, makes sense.