Skip to content
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

Support using without alloc #31

Open
katyo opened this issue Aug 4, 2024 · 1 comment
Open

Support using without alloc #31

katyo opened this issue Aug 4, 2024 · 1 comment

Comments

@katyo
Copy link

katyo commented Aug 4, 2024

I try this awesome library to create firmware for microcontrollers.
Because it supports no_std I expected it works but seems currently Encoder and Decoder implementations uses Vec type from std/alloc. I got the following errors:

error[E0412]: cannot find type `Vec` in this scope

I added dependency as follows:

[dependencies.bitcode]
version = "0.6"
default-features = false
features = ["derive"]

Is it possible to use this crate without std and alloc at all?

@finnbear
Copy link
Member

finnbear commented Aug 4, 2024

bitcode needs alloc (see the README)

Dropping the alloc dependency would require some redesigning and refactoring, and would probably add complexity. You're welcome to try writing a PR to do it (I'd be interested to see how far you can get). I anticipate you would need to use a lot of stack-allocated, fixed-sized vectors that abort instead of growing.

@finnbear finnbear changed the title Using derive for types in no_std context Support using without alloc Aug 4, 2024
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

No branches or pull requests

2 participants