Open sharkdp opened 3 months ago
For the implementation of this function, I wanted to have something like
struct MixedUnitComponent<D: Dim> {
unit: D,
name: String,
}
in order to pass just one List<MixedUnitComponent<D>>
argument around instead of two synchronized lists List<D>
and List<String>
.
This would also be useful for the implementation of the plotting functionality, which currently falls back to Scalar
s using value_of
. And the unit names are transported in the string arguments :roll_eyes:
struct _PlotData {
x_label: String, # something like "length [m]"
y_label: String,
xs: List<Scalar>,
ys: List<Scalar>,
}
It would be much nicer to be able to write
struct _PlotData<X: Dim, Y: Dim> {
x_label: String, # only "length"; unit can be determined from `xs`
y_label: String,
xs: List<X>,
ys: List<Y>,
}
Early draft: https://github.com/sharkdp/numbat/pull/514
Another example where this is needed: #529
With the recent changes to generics in #443, it might not be too hard to support generic structs. As in:
or maybe