feat: Add a feature to disable map support#3
feat: Add a feature to disable map support#3DeltaEvo wants to merge 3 commits intoredbadger:mainfrom
Conversation
The `map` feature, enabled by default, can be disable to remove map support, for codebases not supporting diffs over map to be expressed. See redbadger/pathogen#1 for some context on when map support might not be present.
5ca7429 to
bd28515
Compare
|
Hey @DeltaEvo thanks for this. I fixed some formatting but CI is still failing. The tests fail for |
|
Thanks for helping with the CI, will take a look at the test failure. You're not being dumb, my fault for being too lazy to do a correct explanation 😅 . So the issue is that the patch format (Update or Splice) used by pathogen cannot express removing a non numbered key from something (we could cheat by making it a Update to null but then how do you represent a Map<K, Option>). This is also why the map visitor implementation of difficient is incomplete, currently if it it encounters a removed key, it panics, this is another issue, to fix it we need to extend the Visitor trait to add a Focusing back on the main topic, we are left with two solutions:
|
|
@DeltaEvo thanks for the additional context. I understand better now. I agree that there should be a first-class way to signify a delete (as an alternative to splice for lists, and as a sound way to remove keys in a map). But I'm not sure how putting maps behind a feature in this crate helps. What are the situations in which this feature would be enabled/disabled? |
|
It would be disabled for users that don’t want to add this extra operation just to support maps, basically turning using a map for a Diffable struct an Error. For example, I want to disable it for Photoroom and prevent using maps in the view model so that we can express all updates with just Update and Splice. |
|
Right. Cool. Thanks. We should still add the changes to pathogen I reckon :-) And I'm not quite sure how ordering matters with maps, but that's a discussion we can have in that repo. |
|
I can’t be there for today’s crux community meeting as it’s a day off in France, but I can bring that topic for next week. PS: Sorry for the test, should have ran the full command, will fix them asap |
|
That'd be great. There isn't a call today (it's once a month), so hopefully see you on Tuesday |
7e7b787 to
4f24f7b
Compare
The
mapfeature, enabled by default, can be disable to remove map support, for codebases not supporting diffs over map to be expressed.See redbadger/pathogen#1 for some context on when map support might not be present.
Also in the current codebase, removing a value from a map, trigger an
unimplemented!difficient/src/serde_visit.rs
Line 178 in 7d616b8