Add getters for current configuration values#681
Add getters for current configuration values#681VictorKoenders merged 2 commits intobincode-org:trunkfrom
Conversation
This was inspired by suggestions provided in bincode-org#598, thanks a lot to @VictorKoenders. Fixes bincode-org#598.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## trunk #681 +/- ##
==========================================
- Coverage 57.32% 57.24% -0.08%
==========================================
Files 51 51
Lines 4344 4350 +6
==========================================
Hits 2490 2490
- Misses 1854 1860 +6 ☔ View full report in Codecov by Sentry. |
|
Sorry for the late response, I was going to think about this over the weekend and then Factorio happened and now it's a month later. A couple of things we've been thinking about:
Other than that it looks good, thanks for the contribution! |
|
Thanks for the merge, I think PartialEq and Eq are needed to ensure you can actually do something with the config values. Debug could be nice, but is not required to do something useful. Or perhaps I misunderstood your question? |
|
You understood my question correctly.
You can still match on the variants. This is what we do in bincode currently, the following code will still work without Ok(match D::C::ENDIAN {
Endianness::Little => u16::from_le_bytes(bytes),
Endianness::Big => u16::from_be_bytes(bytes),
})But this will not: if D::C::ENDIAN == Endianness::Little {
panic!("Only big endian supported");
}But I'm also not sure if there's a downside to adding this |
This was inspired by suggestions provided in #598, thanks a lot to @VictorKoenders.
Fixes #598.