Skip to content

jw3126/StructHelpers.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StructHelpers

Stable Dev Build Status Coverage

Sometimes defining a new struct is accompanied by a bit of boilerplate. For instance the default definition of Base.hash is by object id. Often a hash that is based on the object struture is preferable however. Similar for ==. StructHelpers aims to simplify the boilerplate required for such common tweaks.

Usage

struct S
    a
    b
end

@batteries S
@batteries S hash=false # don't overload `Base.hash`
@batteries S kwconstructor=true # add a keyword constructor

For all supported options and defaults, consult the docstring:

julia>?@batteries

Alternatives

  • AutoHashEquals requires annotating the struct definition. This can be inconvenient if you want to annotate the definition with another macro as well.
  • StructEquality is similar to this package.

About

Automate common struct definition boilerplate

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages