-
Notifications
You must be signed in to change notification settings - Fork 372
Labels
Description
Once #10678 gets merged, all values with a type T will lower to a type T from comptime to runtime except CtString. To avoid this exception, CtString should be lowered into a CtString. Users should still have a way to convert a CtString into a string, the same way they can convert a fmtstr into a string.
Lowering a CtString
Given this code:
use std::append::Append;
fn main() {
let ct_string = comptime {
let mut ct_string = CtString::new();
ct_string = ct_string.append("Hello");
ct_string = ct_string.append(" world");
ct_string
};
}It can be lowered like this:
fn main() {
let ct_string = comptime { std::append::Append::append(CtString::new(), "Hello world") };
}That is, we can always lower it with an expression std::append::Append::append(CtString::new(), <CtString contents>).
Turning a CtString into str
CtString already has a as_quoted_str method for this.
Reactions are currently unavailable