Skip to content

format! macro in no_std, no alloc environment #383

Answered by jessebraham
ewrogers asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure this is possible without allocations; there may be some way but I'm not familiar with any off the top of my head.

We do provide the esp-alloc crate which will allow you to perform allocations using esp-hal and only requiring core + alloc. This gives you access to collections, strings, etc. and in turn the format! macro.

The format_args! macro is available in core and in some instances can be used instead (IIRC format! just ends up calling format_args! anyway) however this macro returns the type core::fmt::Arguments, not a String or &str. Some APIs are able to consume this type, however.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ewrogers
Comment options

Answer selected by ewrogers
Comment options

You must be logged in to vote
1 reply
@ewrogers
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants