-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deeper integration with Serde #13
Comments
I can see this when used in conjunction with a deserialzable. Keep in mind that in the general case, I'd want this library to remain weakly typed. For instance, suppose that yaml was: font:
use_thin_strokes: 1
I don't mind having some way to change this to a more strict typing, as long as the API to do so feels fine. |
The DeserializeSeed approach is 100% compatible with remaining weakly typed. |
Looking into this. I want to get this crate solid. We can't easily run directly against the configuration source because of deep merging. A I've been playing around with this and can now propagate simple type errors like ("tru" -> "true"). I'm planning to add locality to the error messages by tracking where each value came from in the main configuration hash by defining the hash as A enum ValueSource {
File { row: usize, column: usize },
Uri(String)
} I do have a couple questions for you, @dtolnay (and anyone else watching).
|
This is all now on master |
…on-3.x chore(deps): update github/codeql-action action to v3
Loading configuration directly using Serde produces way better error messages than this crate. By converting everything to config::Value you lose all the valuable information about where everything came from.
As an example of good error messages, the config in Alacritty contains:
They load it like this:
Suppose somebody typos a boolean:
The error would look like:
The error message gives the exact line and column to fix the error.
I think it should be possible to improve by implementing config::get as a
DeserializeSeed
that runs against the original config source (the yaml file or whatever). Basically the seed is the key that you are looking up and the DeserializeSeed implementation will deserialize that key from the config file, keeping track of whether that key was found. If not found, it can try again on the next source.The text was updated successfully, but these errors were encountered: