Compare commits

...

5 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire bfa7c6020f View
- Fixed range-based `opSlice(...)`

View (unittests)

- Added unittest
2024-05-02 08:35:45 +02:00
Tristan B. Velloza Kildaire 2ecb371d9a View
- Added range `opSlice()`
2024-05-02 08:34:28 +02:00
Tristan B. Velloza Kildaire a2fc15aac1 Merge branch 'master' into feature/views 2024-05-02 08:33:15 +02:00
Tristan B. Velloza Kildaire b6106883da ConfigEntry
- Space fix
2024-05-02 08:32:38 +02:00
Tristan B. Velloza Kildaire 29064908e7 niknaks.functional
- Cleaned up
2024-05-02 08:15:00 +02:00
3 changed files with 10 additions and 5 deletions

View File

@ -345,7 +345,6 @@ public struct ConfigEntry
{
return numeric();
}
else static if(__traits(isSame, T, string[]))
{
return array();

View File

@ -754,6 +754,13 @@ if(isSector!(SectorType)())
return buff;
}
public T[] opSlice(size_t start, size_t end)
{
// FIXME: This is lazy, do a check for up to where
// and actually make THIS the real implementation
return this.opSlice()[start..end];
}
private static bool isArrayAppend(P)()
{
return __traits(isSame, P, T[]);
@ -887,6 +894,7 @@ unittest
assert(view[1] == 3);
assert(view[2] == 45);
assert(view[3] == 2);
assert(view[0..2] == [1,3]);
// Update elements
view[0] = 71;

View File

@ -5,7 +5,8 @@
*/
module niknaks.functional;
import std.traits : isAssignable;
import std.traits : isAssignable, isFunction, isDelegate, ParameterTypeTuple, ReturnType;
import std.functional : toDelegate;
/**
* Predicate for testing an input type
@ -25,9 +26,6 @@ template Predicate(T)
alias Predicate = bool delegate(T);
}
import std.traits : isFunction, isDelegate, ParameterTypeTuple, isFunction, ReturnType;
import std.functional : toDelegate;
/**
* Given the symbol of a function or
* delegate this will return a new