const_format_crates
const_format_crates copied to clipboard
Cannot use concatcp to match str
Hello, currently I am having an issue when trying to match strings using concatcp
:
Let suppose we have following code:
use const_format::concatcp;
fn main() {
const ABC: &str = "abc/";
let s = "abc/xyz";
match s {
concatcp!(ABC, "xyz") => todo!(),
_ => todo!()
}
}
In compilation, I get following error:
Using std's concat
macro works, but with concatcp I can use a constant to avoid repetitions, in this case, of abc/
.
Thank you for this crate!
There's no way on stable to make that work yet, so you'll have to do this for now:
use const_format::concatcp;
fn main() {
const ABC: &str = "abc/";
let s = "abc/xyz";
const C: &str = concatcp!(ABC, "xyz");
match s {
C => todo!(),
_ => todo!()
}
}
when inline const is stabilized, then I'll update this crate to use it and make your code work.
I'll leave this issue open until that happens.