[][src]Macro const_format::concatc

macro_rules! concatc {
    () => { ... };
    ($($anything:tt)*) => { ... };
}

Concatenates constants of standard library and/or user-defined types into a &'static str.

User defined types must implement the FormatMarker trait and and have a const_display_fmt method (as described in the trait) to be concatenated.

Limitations

This macro has the limitations described in here.

Examples

With standard library types

#![feature(const_mut_refs)]

use const_format::concatc;

assert_eq!(concatc!("There is ", 99u8, " monkeys!"), "There is 99 monkeys!");

With user-defined types

#![feature(const_mut_refs)]

use const_format::{Formatter, Sliced, concatc, impl_fmt};

const STRING: &str = "foo bar baz";

assert_eq!(concatc!(Sliced(STRING, 4..8), Foo), "bar table");

struct Foo;

impl_fmt!{
    impl Foo;
    const fn const_display_fmt(&self, fmt: &mut Formatter<'_>) -> const_format::Result {
        fmt.write_str("table")
    }
}