Mercurial > repos > public > sbplib_julia
comparison src/StaticDicts/StaticDicts.jl @ 737:ca4f17efb279 feature/static_dict
Change to using DomainError
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 17 Mar 2021 21:47:16 +0100 |
parents | b5d9fbcdcef1 |
children | e716602f1d62 |
comparison
equal
deleted
inserted
replaced
736:b5d9fbcdcef1 | 737:ca4f17efb279 |
---|---|
23 struct StaticDict{K,V,N} <: AbstractDict{K,V} | 23 struct StaticDict{K,V,N} <: AbstractDict{K,V} |
24 pairs::NTuple{N,Pair{K,V}} | 24 pairs::NTuple{N,Pair{K,V}} |
25 | 25 |
26 function StaticDict{K,V,N}(pairs::Tuple) where {K,V,N} | 26 function StaticDict{K,V,N}(pairs::Tuple) where {K,V,N} |
27 if !allunique(first.(pairs)) | 27 if !allunique(first.(pairs)) |
28 throw(ArgumentError("keys must be unique (for now)")) | 28 throw(DomainError(pairs, "keys must be unique")) |
29 end | 29 end |
30 return new{K,V,N}(pairs) | 30 return new{K,V,N}(pairs) |
31 end | 31 end |
32 end | 32 end |
33 | 33 |