vigna / sux-rs

Rust implementations of succinct data structures
Apache License 2.0
43 stars 7 forks source link

`Derive(MemDbg)` makes trait non-object safe #55

Open RagnarGrootKoerkamp opened 1 day ago

RagnarGrootKoerkamp commented 1 day ago

MemDbg:mem_dbg{,_depth}_on functions take a &mut impl Write, which prevent doing &dyn MyTrait when MyTrait: MemDbg.

Not quite sure what a good fix is though. Clearly you want to provide the custom writer functionality.

zommiommy commented 1 day ago

I think the easiest solution is to pass around the writer as owned instead of taking the reference

RagnarGrootKoerkamp commented 1 day ago

You could also take a &mut dyn Write, but that could be considered ugly in cases where it's not necessary.

RagnarGrootKoerkamp commented 1 day ago

Oh probably it would make more sense for the default mem_dbg function to write to stderr rather than stdout.