From 7e1049586294771e4b58755df3a0ff2638db6bf6 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 2 Mar 2023 10:55:55 +0200 Subject: [PATCH] Utilities - Moved `flatten()` to the `dlog.utilities` module Package - Updated package to import `dlog.utilities` Core - Import `flatten` from `dlog.utilities` --- source/dlog/core.d | 27 +-------------------------- source/dlog/package.d | 1 + source/dlog/utilities.d | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 26 deletions(-) create mode 100644 source/dlog/utilities.d diff --git a/source/dlog/core.d b/source/dlog/core.d index 5652193..611ad34 100644 --- a/source/dlog/core.d +++ b/source/dlog/core.d @@ -10,6 +10,7 @@ import std.range : join; import dlog.transform : MessageTransform; import dlog.defaults; import dlog.context : Context, CompilationInfo; +import dlog.utilities : flatten; /** * Logger @@ -43,32 +44,6 @@ public class Logger this.multiArgJoiner = multiArgJoiner; } - - - - - /** - * Given an arbitrary amount of arguments, convert each to a string - * and return that as an array - * - * Params: - * segments = alias sequence - * Returns: a flattened string[] - */ - public static string[] flatten(TextType...)(TextType segments) - { - /* The flattened components */ - string[] components; - - /* Flatten the components */ - static foreach(messageComponent; segments) - { - components ~= to!(string)(messageComponent); - } - - return components; - } - /** * Given an arbitrary amount of arguments, convert each to a string * and return it as an array joined by the joiner diff --git a/source/dlog/package.d b/source/dlog/package.d index 78dd292..7174a4c 100644 --- a/source/dlog/package.d +++ b/source/dlog/package.d @@ -9,3 +9,4 @@ public import dlog.core; public import dlog.transform; public import dlog.defaults; public import dlog.context; +public import dlog.utilities; diff --git a/source/dlog/utilities.d b/source/dlog/utilities.d new file mode 100644 index 0000000..bb15816 --- /dev/null +++ b/source/dlog/utilities.d @@ -0,0 +1,23 @@ +module dlog.utilities; + +/** + * Given an arbitrary amount of arguments, convert each to a string + * and return that as an array + * + * Params: + * segments = alias sequence + * Returns: a flattened string[] + */ +public string[] flatten(TextType...)(TextType segments) +{ + /* The flattened components */ + string[] components; + + /* Flatten the components */ + static foreach(messageComponent; segments) + { + components ~= to!(string)(messageComponent); + } + + return components; +} \ No newline at end of file