d不要直接用转串

原文
不要直接用.toString,用std.format.format.

import std;
void main() {
    auto x = BigInt("123123123123123123123123123123123123");
    string s = format("%s", x); // 给你串表示
    writeln(s); // 打印"123123123123123123123123123123123123"

    // 转为dchar[]:
    dstring ds = s.to!(dchar[]);

    // 不用串,直接转为dchar[]
    auto app = appender!(dchar[]);
    app.formattedWrite("%s","x");
    dchar[] dcharArray = app.data; //现在有d符.
}
posted @ 2022-08-04 11:00  zjh6  阅读(9)  评论(0)    收藏  举报  来源