Skip to content

BeastyBlacksmith/ProtoStructs.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProtoStructs.jl

Run tests Codecov

You are developing a new datastructure and are tired of restarting everytime you change your mind? ProtoStructs lets you have structs which behave like they would have been redefined.

Here is how it works:

using ProtoStructs

@proto @kwdef struct DevType{T}
    a::T = 1
    b::Float64 = 2.0
    c
end
a = DevType(a=1, b=2.0, c="3")
b = DevType(c=:boo)
c = DevType(2, 4.0, nothing)

@proto @kwdef mutable struct DevType{T1, T2}
    a::T1 = 1
    b::T2 = 2.0
    c
end
a = DevType(a=1, b=2.0, c="3")
b = DevType(c=:boo)
c = DevType(2, 4.0, nothing)

Redefine at will, but remove the @proto macro after developing to ensure correctness and improve performance of your code.


For julia VERSION < v"1.8" there is also Redef.