[parity-bytes] add no-std support #154
Conversation
|
It looks like @bradyjoestar hasn't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement at the following URL: https://cla.parity.io Once you've signed, please reply to this thread with Many thanks, Parity Technologies CLA Bot |
|
: [clabot:check] |
|
It looks like @bradyjoestar signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
| extern crate alloc; | ||
|
|
||
| // Re-export libcore using an alias so that the macros can work without | ||
| // requiring `extern crate core` downstream. |
There was a problem hiding this comment.
Not sure I understand what you mean by "the macros" – are there macros exported from this crate?
There was a problem hiding this comment.
to be fair it seems to be copy-pasted across many crates: https://github.com/search?l=Rust&q=Re-export+libcore+using+an+alias+so+that+the+macros+can+work+without&type=Code
There was a problem hiding this comment.
I get it from the elastic-array and it have some marcos exported.
https://github.com/debris/elastic-array/blob/8f01572f850e6f387ad785fb1e59d599eb260ea0/src/lib.rs#L11-L28
I'm not sure whether will be some macros exported from this crate, so I didn't delete it 😄
There was a problem hiding this comment.
So if we’re not doing it for the macros, then what is the purpose of this re-export? Can we remove it?
There was a problem hiding this comment.
I delete the re-export,it show the following errors:
https://travis-ci.org/paritytech/parity-common/jobs/533187061#L1447
https://ci.appveyor.com/project/paritytech/parity-common/builds/24584892
There was a problem hiding this comment.
So I think you need to do:
#[cfg(feature = "std")]
extern crate core;
(notice no pub)
…and then replace use core_::{… … with use core::{… ….
The idea is that when running with std you need to import the core as a crate. In no_std mode core is part of the prelude.
There was a problem hiding this comment.
Thanks for your guide!
|
Would be nice adding a README with a no-std section to parity-bytes (explaining it's currently nightly-only), similar to https://github.com/paritytech/parity-wasm#no_std-crates |
|
I have met the similar error when running cargo +nightly test --no-default-features: #[macro_use] is added and I had forgot the |
ordian
left a comment
There was a problem hiding this comment.
Could you add cd parity-bytes; cargo build --no-default-features; cd .. for nightly in .travis.yml, cf.
https://github.com/paritytech/parity-wasm/blob/6aaa9648a6fcb97d143a0f35a0e2b6dfa4d3f00a/.travis.yml#L17
Co-Authored-By: Andronik Ordian <write@reusable.software>
Co-Authored-By: Andronik Ordian <write@reusable.software>
|
|
||
| ```toml | ||
| [dependencies] | ||
| parity-bytes = { version = "0.1.1", default-features = false } |
There was a problem hiding this comment.
This is a nitpick but let’s do version = “0.1”.
| extern crate alloc; | ||
|
|
||
| // Re-export libcore using an alias so that the macros can work without | ||
| // requiring `extern crate core` downstream. |
There was a problem hiding this comment.
So if we’re not doing it for the macros, then what is the purpose of this re-export? Can we remove it?
| extern crate alloc; | ||
|
|
||
| #[doc(hidden)] | ||
| extern crate core; |
There was a problem hiding this comment.
There was a problem hiding this comment.
|
@bradyjoestar thank you for your work here! :) |
|
my pleasure! :) |
…fix/zero-memory-for-hmac-signing-keys * 'master' of github.com:paritytech/parity-common: [parity-bytes] add no-std support (#154)
* paritytech/master: [parity-bytes] add no-std support (paritytech#154) [parity-crypto] Derive Debug for digests and signatures (paritytech#155) Restore the previous API to allow variable size keys for Hmac operations (paritytech#152) Implemented TryFrom<biguint> for primitives (paritytech#148)
* master: [parity-crypto] zero memory for hmac signing keys (#157) Added absolute path for 'Result' usage in macros to avoid type collisions. (#160) [parity-bytes] add no-std support (#154) [parity-crypto] Derive Debug for digests and signatures (#155) Restore the previous API to allow variable size keys for Hmac operations (#152) Implemented TryFrom<biguint> for primitives (#148)
Fixes #153