commit
4438b542b2
14
.codecov.yml
Normal file
14
.codecov.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Documentation: https://docs.codecov.io/docs/codecov-yaml
|
||||
|
||||
coverage:
|
||||
precision: 3
|
||||
round: down
|
||||
range: "80...100"
|
||||
|
||||
status:
|
||||
# Learn more at https://docs.codecov.io/docs/commit-status
|
||||
project: true
|
||||
patch: true
|
||||
changes: true
|
||||
|
||||
comment: false
|
|
@ -3,7 +3,8 @@ TaggedAlgebraic
|
|||
|
||||
Implementation of a generic algebraic data type with a tagged union storage. All operations of the contained types are available for the `TaggedAlgebraic`
|
||||
|
||||
[![Build Status](https://travis-ci.org/s-ludwig/taggedalgebraic.svg?branch=master)](https://travis-ci.org/s-ludwig/taggedalgebraic) [![Coverage Status](https://coveralls.io/repos/s-ludwig/taggedalgebraic/badge.png?branch=master)](https://coveralls.io/r/s-ludwig/taggedalgebraic?branch=master)
|
||||
[![Build Status](https://travis-ci.org/s-ludwig/taggedalgebraic.svg?branch=master)](https://travis-ci.org/s-ludwig/taggedalgebraic) [![codecov](https://codecov.io/gh/s-ludwig/taggedalgebraic/branch/master/graph/badge.svg)](https://codecov.io/gh/s-ludwig/taggedalgebraic)
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
|
|
@ -658,34 +658,35 @@ unittest {
|
|||
}
|
||||
|
||||
|
||||
/** Maps a kind enumeration value to the corresponding field type.
|
||||
static if (__VERSION__ >= 2072) {
|
||||
/** Maps a kind enumeration value to the corresponding field type.
|
||||
|
||||
`kind` must be a value of the `TaggedAlgebraic!T.Kind` enumeration.
|
||||
*/
|
||||
template TypeOf(alias kind)
|
||||
if (isInstanceOf!(TypeEnum, typeof(kind)))
|
||||
{
|
||||
import std.traits : FieldTypeTuple, TemplateArgsOf;
|
||||
alias U = TemplateArgsOf!(typeof(kind));
|
||||
alias TypeOf = FieldTypeTuple!U[kind];
|
||||
}
|
||||
|
||||
///
|
||||
unittest {
|
||||
static struct S {
|
||||
int a;
|
||||
string b;
|
||||
string c;
|
||||
`kind` must be a value of the `TaggedAlgebraic!T.Kind` enumeration.
|
||||
*/
|
||||
template TypeOf(alias kind)
|
||||
if (isInstanceOf!(TypeEnum, typeof(kind)))
|
||||
{
|
||||
import std.traits : FieldTypeTuple, TemplateArgsOf;
|
||||
alias U = TemplateArgsOf!(typeof(kind));
|
||||
alias TypeOf = FieldTypeTuple!U[kind];
|
||||
}
|
||||
alias TA = TaggedAlgebraic!S;
|
||||
|
||||
static assert(is(TypeOf!(TA.Kind.a) == int));
|
||||
static assert(is(TypeOf!(TA.Kind.b) == string));
|
||||
static assert(is(TypeOf!(TA.Kind.c) == string));
|
||||
///
|
||||
unittest {
|
||||
static struct S {
|
||||
int a;
|
||||
string b;
|
||||
string c;
|
||||
}
|
||||
alias TA = TaggedAlgebraic!S;
|
||||
|
||||
static assert(is(TypeOf!(TA.Kind.a) == int));
|
||||
static assert(is(TypeOf!(TA.Kind.b) == string));
|
||||
static assert(is(TypeOf!(TA.Kind.c) == string));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Gets the value stored in an algebraic type based on its data type.
|
||||
*/
|
||||
ref inout(T) get(T, U)(ref inout(TaggedAlgebraic!U) ta)
|
||||
|
|
Loading…
Reference in a new issue