macro_rules! concatc {
() => { ... };
($($anything:tt)*) => { ... };
}
Expand description
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.
§Stable equivalent
For an equivalent macro which can be used in stable Rust,
but can only concatenate primitive types,
you can use the concatcp
macro.
§Limitations
This macro has the limitations described in here.
§Examples
§With standard library types
use const_format::concatc;
assert_eq!(concatc!("There is ", 99u8, " monkeys!"), "There is 99 monkeys!");
§With user-defined types
use const_format::{Formatter, Sliced, concatc, impl_fmt};
const STRING: &str = "foo bar baz";
assert_eq!(concatc!(Sliced(STRING, 4..7), ' ', 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")
}
}