You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let manifest:TomlManifest = serde_ignored::deserialize(toml, |path| {
unused.insert(format!("{}", path));})?;
We could have serde-ignored (perhaps behind a feature flag) leverage something like lev_distance to give suggestions - which the callsite could use as suggestions
Possible new call syntax
let manifest:TomlManifest = serde_ignored::deserialize_with_suggestions(toml,2/* lev distance */, |path:Path,suggestions:Vec<Path>| {if ! suggestions.empty(){print("{} unused. Did you mean {}", path, suggestions[0]);}
unused.insert(stringify(path));})?;
^ which would ideally print "dependencies.serde.feautres unused. Did you mean dependencies.serde.features"
I'm not sure if the idea I gave for this problem is actually achievable. In reading up, I found:
Deserializer for struct might look like this https://serde.rs/deserialize-struct.html
The wrapping deserializer in serde-ignored is passed a visitor, but can't get a list of possible valid strings that the visitor's visit_str would accept, therefore it can't augment self.path with suggestions.
I suppose it could call visitor.visit_str(guess) with a bunch of guesses of short-edit-distance, but that's hardly appetizing.
For example, if deserializing something like
With something like
We could have serde-ignored (perhaps behind a feature flag) leverage something like lev_distance to give suggestions - which the callsite could use as suggestions
Possible new call syntax
^ which would ideally print "dependencies.serde.feautres unused. Did you mean dependencies.serde.features"
Inspired by
rust-lang/cargo#5264 and
rust-lang/cargo#9731
The text was updated successfully, but these errors were encountered: