-
Notifications
You must be signed in to change notification settings - Fork 267
Conversation
crates/hdk/src/prelude.rs
Outdated
/// Types required by all but the most trivial zomes. | ||
/// This can greatly simplify imports for the majority of developers | ||
/// by simply adding use hdk::prelude::*; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really the only file needed to be reviewed. Please check if you think these types are sufficient or if they are too broad. I made a judgement call to include these ones in particular based on the app spec.
@@ -1,41 +1,10 @@ | |||
#![warn(unused_extern_crates)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A great example of why this is awesome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I really like the idea of introducing a prelude! I left one nit about a doc comment. I will point out that a prelude with this many things in it (37!) is pretty unusual.
My understanding is that the best practice for preludes is to create one that only re-exports traits, and even then, use a nameless re-export.
For some (admittedly cherrypicked) examples, tokio and std::io
.
I'm fine with landing this for now since we are trying to make it easy for rapid prototyping, but in the long game, I'm not so sure that it's the API we want.
PR summary
A nice easy review. Adds a new module called
prelude
to the HDK. This is a common pattern among Rust crates and it contains the macros and types that are required to effectively use the crate. In many cases this simplifies theuse
statements in a zome to a single line.As part of this PR I also migrated the zomes not currently using Rust edition 2018 to use it (only the blog zome). This means that
extern crate
is no longer required further simplifying the experience of using the HDK.It also catches a few cases in the HDK macros where it assumed certain types were imported. The imports are now explicit in the macro.
The changes to the HDK are 100% backward compatible!!! So this won't break any existing zome code or examples.
testing/benchmarking notes
( if any manual testing or benchmarking was/should be done, add notes and/or screenshots here )
changelog
Please check one of the following, relating to the CHANGELOG-UNRELEASED.md
- summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)
documentation