Skip to content

lempiji/assign

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

assign

A flexible constructer for immutable struct.

Usage

import assign;

struct Test
{
    string text;
    int number;

    mixin AssignConstructor;
}

void main()
{
    auto test = immutable Test(prop!"text"("test"), prop!"number"(1));
    assert(test.text == "test");
    assert(test.number == 1);

    //rep takes over test's props, and assign the text field.
    auto rep = immutable Test(makeProps(test), prop!"text"("some text"));
    assert(test.text == "test");
    assert(rep.number == 1);
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages