Utilities

- Moved `flatten()` to the `dlog.utilities` module

Package

- Updated package to import `dlog.utilities`

Core

- Import `flatten` from `dlog.utilities`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-02 10:55:55 +02:00
parent 28c546ff16
commit 7e10495862
3 changed files with 25 additions and 26 deletions

View File

@ -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

View File

@ -9,3 +9,4 @@ public import dlog.core;
public import dlog.transform;
public import dlog.defaults;
public import dlog.context;
public import dlog.utilities;

23
source/dlog/utilities.d Normal file
View File

@ -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;
}