-
Notifications
You must be signed in to change notification settings - Fork 7
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
Do not require nightly for no_std #22
Conversation
This seems very reasonable. How urgent is this for you? I am asking, because I plan to do some major rewriting of how this library is in the kernel (make it into its own crate) and the less the userspace version is diverged, the easier it becomes. So if you would not be using it in a couple months, then I will probably have finished the rewrite. But if say you would like to use it in the next couple of weeks, then it wouldn't be an issue to just merge your contribution (since it's so small). What do you think? |
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.
I gave it some more thought and since the change is so small, I think I will go ahead and just merge it and publish a new version.
Thank you for reacting so quickly (and pushing a new version to As for when we plan to start using it in Most important is the other maintainers on the project to understand what I'm trying to address in there and why Needless to say, I'm - in the meantime - a big fan of the Ideally - and over time of course - I would like to see support for it in |
My pleasure!
That sounds great! If you hit anything feel free to open an issue (also if you have any questions regarding usage or think that documentation is unclear etc.).
I plan to eventually create an RFC to get this into the Rust language, since the syntax is not ideal and certain errors are rather difficult to parse... (also it would be nice to have rustfmt understand the marco)
I see, I haven't really thought about use-cases outside of the kernel, since that is what I created this for and I personally don't do embedded. But I'd be happy to see that come to fruition. |
Stack blow-ups in Rust due to memory being moved around are a common source of annoyance in the embedded world. MCUs typically have something like 400KB RAM (and this is the beefy Espressif MCU line). Others have much less. (Of course program size does not count towards these 400KB, MCUs map the flash where the firmware is written via MMU directly in the e.g. the first 64KB of the RAM or so; which is used as a form of program/execution "cache" which is refreshed on "page faults" of sorts; but even the firmware is rarely bigger than 2MB). Even if you are running a single-threaded program (say, with |
This PR puts the
InPlaceInit
trait behind the a#[cfg(feature = "alloc")]
flag, which - in turn - allows us to only require the unstablecore::alloc::AllocError
type when featurealloc
(orstd
) is enabled.Thus, the
no_std
portion of this crate compiles on stable Rust.I need this because
rs-matter
- where we might start usingpinned-init
- requires Rust stable. Sincers-matter
isno_std
(andno-alloc
) we don't really need that much if at all the smart-pointer in-place initialization logic ofInPlaceInit
. Not to mention that itsArc
/Rc
/Box
implementations currently depend on other nightly features anyway so we can't use those.The justification for putting the
InPlaceInit
trait behind thealloc
feature is that I'm struggling a bit to find use cases for it when thealloc
module is not enabled. While it is indeed generic and can be used for custom smart pointers, still:alloc
crateInPlaceInit
, but would rather just implement theinit
method & friends directly on the custom smart pointer?An alternative to the change here is to introduce another feature:
in-place-init
and then hide theInPlaceInit
trait behind this feature, which would be enabled by default whenalloc
is enabled.I'm fine with either of these approaches.
What would be your suggestion?