Macro gstring

Source
macro_rules! gstring {
    ($array: ident, $code: block) => { ... };
}
Expand description

A helper to build a string on the stack.

Given an array it makes a writeable cursor available to the passed code block.

Returns a &str slice pointing at memory between the array start and the cursor.

Example:

use core::mem::MaybeUninit;
use std::io::Write;
#[allow(invalid_value)] let mut foobar: [u8; 128] = unsafe {MaybeUninit::uninit().assume_init()};
let foobar = gstring! (foobar, {
    write! (foobar, "foo") .expect ("!write");
    write! (foobar, "bar") .expect ("!write");
});

Alternatives: https://crates.io/crates/stack.