Skip to content

Conversation

@AlisCode
Copy link
Contributor

@AlisCode AlisCode commented Jan 7, 2026

Contents

This PR brings support for no-std in exn so that the crate can be used on e.g. embedded devices.

alloc is still required because of implementation details. At a glance, no-alloc should be possible but is out of scope for this PR and most likely for exn itself.

Fixes #21

@AlisCode AlisCode changed the title Support for #![no_std] feat: Support for #![no_std] Jan 7, 2026
@tisonkun tisonkun requested a review from andylokandy January 15, 2026 08:39
@tisonkun
Copy link
Contributor

@AlisCode This impl still requires alloc. Do you have a real-world use case where alloc is available but no_std can still benefit?

@AlisCode
Copy link
Contributor Author

@tisonkun Yes, for example embedded development.

no-std does not necessarily mean no heap-alloction.

In the case of development for an esp32 for example, you can use esp-alloc to setup your heap, and then you get heap allocation in a no-std context. This allows you to use Rust's goodies like Vec, or in exn's context, Box.

@AlisCode
Copy link
Contributor Author

To add to that : I believe it is theoretically possible to go no-alloc by using heapless, but it would probably change the ergonomics of the library, so I think this is a no-goal for exn.

@tisonkun
Copy link
Contributor

tisonkun commented Jan 16, 2026

Thanks for your explanation!

In my use case, I can have std always available. So I'd keep no_std as a possible nice-to-have option and may not support it when it's too restricted (or, make the code too complex to work).

I'll review this changeset later this month (feel free to ping me if I miss this target).

cc @andylokandy do you foresee some cases we could have hard dependencies on std?

@andylokandy
Copy link
Contributor

anyhow supports #![no_std], and opts-out Backtrace when std is unavailable. I believe exn will not even depend on Backtrace.

@tisonkun
Copy link
Contributor

tisonkun commented Jan 18, 2026

I'm going to rebase this onto the main branch, and add a chaneglog file to denote the no_std support, and emphasize that this is a nice-to-have feature that I do not promise to keep it in the following major versions.

Before 1.0, when the APIs of exn settle down, we can make the final decision whether or not keep no_std a promise. So far, it doesn't seem to hurt our major APIs.

Signed-off-by: tison <wander4096@gmail.com>
Signed-off-by: tison <wander4096@gmail.com>
Copy link
Contributor

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

We may update the README.md for further no_std support details.

@andylokandy I'm going to merge this patch in hours or tomorrow.

Signed-off-by: tison <wander4096@gmail.com>
@tisonkun
Copy link
Contributor

Docs updated also.

@tisonkun tisonkun merged commit bf064b6 into fast:main Jan 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for no-std

3 participants