-
Notifications
You must be signed in to change notification settings - Fork 5
Write extensive documentation on the crate and the macro #20
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
Conversation
8ba9c58 to
65bdbf5
Compare
dureuill
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README motivates the need for the library really well, and explains the available options clearly.
I have a few suggestions, see inline comments
loiclec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! Thank you so much for making deserr such a proper, well-documented, well-tested, ambitious crate :-)
| }, | ||
| location, | ||
| )) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would really like at least one example where a custom function provided by the user returns a non-generic type. Maybe we can add one after the error container/field attribute is explained. Maybe also as an example for the MergeWithError trait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's true, it would be nice to show how to use the MergeWithError trait
dureuill
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful README. I have a couple of additional suggestions but feel free to apply or not.
(other reviewers might also have outstanding comments)
6c2e1d8 to
9682afb
Compare
loiclec
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thank you :)
I added a few more comments. The only ones that are truly important are those that concern outdated derive attribute names and code samples. Otherwise, I would approve it!
Outdated code samples:
The following still uses Result in the comment instead of ControlFlow:
impl DeserializeError for MyError {
/// Create a new error with the custom message.
///
/// Return `Ok` to continue deserializing or `Err` to fail early.
fn error<V: IntoValue>(_self_: Option<Self>, error: ErrorKind<V>, location: ValuePointerRef) -> ControlFlow<Self, Self> {
ControlFlow::Break(Self::Other(take_cf_content(JsonError::error(None, error, location))))
}
}(Also: should we rename the parameters of merge from (self_, other, ...) to (existing/prev, next/new)?)
I didn't check, but is the following implementation necessary?
impl From<JsonError> for MyError {
fn from(error: JsonError) -> Self {
Self::Other(error)
}
}Other suggestions:
I wrote the "Robert '); DROP TABLE Students; --" code sample, but I don't find it very nice anymore. It seems a bit complicated because we implement all the traits manually, but at the same time it does not show many benefits of deserr. I think it undersells it. Maybe we could move it at the end, or instead link to an example code instead? For example, here's how you would implement the trait manually: <link to example file>. Also, maybe saying something lile:
deserroffers a derive proc macro to automatically implementDeserrfor your types. However, unlike serde, it is also very easy to implement these traits manually. See <this file/folder> etc...
| assert_eq!(err.to_string(), "Unknown field `doggo`: expected one of `query`"); | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future improvement: don't say one of when there is only one accepted field?
| | tag+content | yes | no | | | ||
| | untagged | yes | no | it's only supported for unit enums | | ||
| | bound | yes | no | Can be emulated with `where_predicate` | | ||
| | default | yes | no | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No for deserr, but mostly not applicable or not needed, right? Because we have made the choice to force the use of the default field attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think that’s related?
We could let people have a default container attribute so you don’t have to specify it as a field attribute right?
9682afb to
2531096
Compare
document the features starts working on a « why should I use deserr » part finish the into fix a typo + document the needs_predicate fix typos add a small faq start to update the README's examples to doctests makes all code samples compile improve the intro and move the comparison with serde in the comparison with serde part Apply suggestions from code review Co-authored-by: Louis Dureuil <louis.dureuil@gmail.com> apply most suggestions add a sentence explaining what __Deserr_E is apply last review suggestion
3a1f08c to
e4c1a62
Compare
Fix #14