import flod : array; import std.array : appender; import std.format : formattedWrite; import std.range : put; // Create an pipeline object that can be used as output range auto app = appender!string; auto p = pass!char.copy(app); put(p, "Hello, world!\n"); p.formattedWrite("The answer is: %d\n", 42); assert(app.data == "Hello, world!\nThe answer is: 42\n"); // Write to a pipeline from a lambda auto s = pass!(char, (r) { put(r, "Hello, lambda world!\n"); r.formattedWrite("The answer is still %d\n", 42); }) .array(); assert(s == "Hello, lambda world!\nThe answer is still 42\n");