macro_rules! str_splice_out {
($string:expr, $index:expr, $insert:expr $(,)*) => { ... };
}
Expand description
Alternative version of str_splice
which only returns the string
with the applied replacement.
§Example
use const_format::{str_splice_out, SplicedStr};
const OUT: &str = str_splice_out!("foo bar baz", 4..=6, "is");
assert_eq!(OUT , "foo is baz");
// You can pass `const`ants to this macro, not just literals
{
const IN: &str = "this is bad";
const INDEX: std::ops::RangeFrom<usize> = 8..;
const REPLACE_WITH: &str = "... fine";
const OUT: &str = str_splice_out!(IN, INDEX, REPLACE_WITH);
assert_eq!(OUT , "this is ... fine");
}
{
const OUT: &str = str_splice_out!("ABC豆-", 3, "DEFGH");
assert_eq!(OUT , "ABCDEFGH-");
}