In the PineTime Debugger when inspecting Rust variables, we'll see strings mashed together like...
I AM PINETIMEcalled...
This highlights an important difference between Rust Strings and C Strings. C Strings are stored with a null as the last character. (We call this the Terminating Null)
Rust Strings are stored as two components: String Length and String Contents. The String Length is stored in a field named length
. (We can see this in the debugger)
The String Contents for all Rust Strings are mashed together into the same memory space, without the Terminating Null... Because we already have a String Length that tells us how to extract our String Contents from the mashup.
When passing Rust Strings to C Functions (like Mynewt Functions), it's important to convert the strings correctly.