format! macro in no_std, no alloc environment #383
-
I feel like a bit of a Rust newbie asking something so trivial, but I am trying to figure out a way to do Every example of this uses I thought a library like What is the general convention for needing to do string formatting in a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
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 The |
Beta Was this translation helpful? Give feedback.
-
Another option would be the Heapless crate |
Beta Was this translation helpful? Give feedback.
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 requiringcore
+alloc
. This gives you access to collections, strings, etc. and in turn theformat!
macro.The
format_args!
macro is available incore
and in some instances can be used instead (IIRCformat!
just ends up callingformat_args!
anyway) however this macro returns the typecore::fmt::Arguments
, not aString
or&str
. Some APIs are able to consume this type, however.