From 65fcbbf16fa37eebbfa55f68355ce741c9b55a72 Mon Sep 17 00:00:00 2001 From: Jack Stouffer Date: Fri, 9 Mar 2018 08:49:34 -0500 Subject: [PATCH] Improve documented example --- std/base64.d | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/std/base64.d b/std/base64.d index 88792f107..e844bde1c 100644 --- a/std/base64.d +++ b/std/base64.d @@ -454,20 +454,15 @@ template Base64Impl(char Map62th, char Map63th, char Padding = '=') /// @safe pure nothrow unittest { - // @system because encode for OutputRange is @system - struct OutputRange - { - char[] result; - void put(const(char) ch) @safe { result ~= ch; } - } + import std.array : appender; + auto output = appender!string(); ubyte[] data = [0x1a, 0x2b, 0x3c, 0x4d, 0x5d, 0x6e]; // This overload of encode() returns the number of calls to the output // range's put method. - OutputRange output; assert(Base64.encode(data, output) == 8); - assert(output.result == "Gis8TV1u"); + assert(output.data == "Gis8TV1u"); }