AutomotiveSimulator.jl
AutomotiveSimulator.jl copied to clipboard
`SpeedLimit` has no `iterate` method
It would be nice to be able to iterate over or splat a SpeedLimit object since it is a tuple-like object. For example, splatting into a Distribution
object or into a clamp
statement to avoid having to type everything out would be super convenient (it is not too tedious, but it would be convenient :) )
Currently, both of these throw a MethodError: no method matching iterate(::SpeedLimit)
, which makes sense.
Uniform(SpeedLimit(0., 10.)...) # using Distributions
clamp(velocity, SpeedLimit(0., 10.)...)
That would be a neat feature, instead of implementing iterate
for SpeedLimit
would it make sense to make it a FieldVector
or a NamedTuple`?
The other option is to implement iterate
which is not that big of a deal.
I am pretty sure there must be some julia package with a macro that defines it for us for any structure.
For example there is @unpack
: https://github.com/mauro3/Parameters.jl