ayrat555 / frankenstein

Telegram bot API client for Rust
Do What The F*ck You Want To Public License
268 stars 28 forks source link

Migrate to builder with compile time checks #46

Closed EdJoPaTo closed 2 years ago

EdJoPaTo commented 2 years ago

The used derive_builder crate does the checks on runtime. Something like the following will compile but fail at runtime creating hard to find mistakes. Especially as Telegram interactions are not always tested this easily allows for mistakes.

SendMessageParamsBuilder::default().build().expect("I will fail");
I will fail: UninitializedField("chat_id")

typed-builder does this at compile time which will result in less .unwrap(), better performance and less mistakes in production as mistakes are found at compile time. I haven't tried migrating to typed-builder so there might be something preventing it to be used.

Switching the builder system will result in a breaking change but this seems worth it for me.

Any thought on that?

ayrat555 commented 2 years ago

@EdJoPaTo I don't have anything against this. I think we can try this crate