However, if I have many structs, each with several fields, this becomes a bit tedious. Is there a way to do this automatically through a macro or something?
You can also do this, depending on the complexity of the structures:
julia> struct A
x
y
end
julia> a = A(1,2); b = A(1,2)
A(1, 2)
julia> import Base: ==
julia> ==(a::A,b::A) = all(getfield(a,f) == getfield(b,f) for f in fieldnames(A))
== (generic function with 198 methods)
julia> a == b
true