Attempts to introduce a Miniconf<Style> trait with Leaf and Internal styles.
This should replace the newtype array and Options and the "#[miniconf(defer)]" attribute in favor of #[miniconf(defer=n)] with a depth n indicating how many levels to defer instead.
The default would be depth=0 (for which it then bounds the field as Miniconf<Leaf> and uses that).
For depth>0 it bounds T as Miniconf<Internal> and uses that when recursing.
The inner array would need to know about the attributes.
Instead we need to pass the defer depth down decremented in the methods.
That #[miniconf(n)] will the nicely mesh with indices.take(n).
We'd enforce that the depth match:
struct T {
#[miniconf]
a: Option<i32>,
}
struct S {
#[miniconf(defer=0)]
d: Option<i32>,
#[miniconf(defer=1)]
d: Option<T>,
#[miniconf(defer=1)]
b: [i32; 2],
#[miniconf(defer=2)]
c: [T; 2],
#[miniconf] // this could error (at run-time) because T may not do homogeneous depth or even not do the depth spec'd at all.
s: T,
}
There doesn't seem a different good way to handle the inner attributes.
[ ] it should be impl<Y: Style, T: Miniconf<Y>, const N: usize> Miniconf<Internal> for [T; N] and not just T: Miniconf<Outer>
[ ] clear up the depth and style definitions for Option which may well have depth=0 vs [T;N] which never has.
Incomplete.
Attempts to introduce a
Miniconf<Style>
trait withLeaf
andInternal
styles. This should replace the newtype array and Options and the "#[miniconf(defer)]" attribute in favor of#[miniconf(defer=n)]
with a depthn
indicating how many levels to defer instead. The default would bedepth=0
(for which it then bounds the field asMiniconf<Leaf>
and uses that). Fordepth>0
it boundsT
asMiniconf<Internal>
and uses that when recursing.Take this as an non-workable alternative:
The inner array would need to know about the attributes. Instead we need to pass the defer depth down decremented in the methods. That
#[miniconf(n)]
will the nicely mesh withindices.take(n)
.We'd enforce that the depth match:
There doesn't seem a different good way to handle the inner attributes.
impl<Y: Style, T: Miniconf<Y>, const N: usize> Miniconf<Internal> for [T; N]
and not justT: Miniconf<Outer>
Option
which may well have depth=0 vs[T;N]
which never has.