-
Notifications
You must be signed in to change notification settings - Fork 245
[parity-bytes] add no-std support #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
544fcd0
7ca23a6
8421dc3
f1ad6ad
44022f0
979aefa
5b6a0a0
bc08d43
64698e5
6fddc6e
7c73083
afabd61
617df71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,28 @@ | |
| //! Includes a pretty-printer for bytes, in the form of `ToPretty` and `PrettySlice` | ||
| //! as | ||
|
|
||
| use std::fmt; | ||
| use std::cmp::min; | ||
| use std::ops::{Deref, DerefMut}; | ||
| #![cfg_attr(not(feature = "std"), no_std)] | ||
| #![cfg_attr(not(feature = "std"), feature(alloc))] | ||
|
ordian marked this conversation as resolved.
|
||
|
|
||
| #[cfg(not(feature = "std"))] | ||
| extern crate alloc; | ||
|
|
||
| // Re-export libcore using an alias so that the macros can work without | ||
| // requiring `extern crate core` downstream. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understand what you mean by "the macros" – are there macros exported from this crate?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get it from the I'm not sure whether will be some macros exported from this crate, so I didn't delete it 😄
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if we’re not doing it for the macros, then what is the purpose of this re-export? Can we remove it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed. 👌
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I delete the re-export,it show the following errors:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think you need to do: (notice no …and then replace The idea is that when running with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your guide! |
||
| #[doc(hidden)] | ||
| pub extern crate core as core_; | ||
|
|
||
| use core_::{ | ||
| cmp::min, | ||
| fmt, | ||
| ops::{Deref, DerefMut}, | ||
| }; | ||
|
|
||
| #[cfg(not(feature = "std"))] | ||
| use alloc::vec::Vec; | ||
|
|
||
| #[cfg(feature = "std")] | ||
| use std::vec::Vec; | ||
|
|
||
| /// Slice pretty print helper | ||
| pub struct PrettySlice<'a> (&'a [u8]); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.