ChainSafe / forest

🌲 Rust Filecoin Node Implementation
https://forest.chainsafe.io
Apache License 2.0
617 stars 145 forks source link

chore: simplify a few Display implementations with displaydoc #4447

Closed hanabi1224 closed 1 week ago

hanabi1224 commented 1 week ago

Summary of changes

Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes

Other information and links

https://crates.io/crates/displaydoc

Change checklist

LesnyRumcajs commented 1 week ago

@hanabi1224 do we need another dependency or could we reuse strum? https://docs.rs/strum/latest/strum/derive.Display.html

hanabi1224 commented 1 week ago

do we need another dependency or could we reuse strum? https://docs.rs/strum/latest/strum/derive.Display.html

@LesnyRumcajs According to the doc, strum converts enum variants to strings.. while displaydoc also supports structs. Using displaydoc does not expand our dependency tree, as it's one of the indirect dependencies. Popularity wise, displaydoc is among top 100 crates(that are available on the Rust playground).

#[derive(displaydoc::Display)]
#[serde(transparent)]
#[displaydoc("{0}")]
pub struct StrictAddress(pub Address);