Skip to content

Conversation

@irevoire
Copy link
Contributor

@irevoire irevoire commented Jan 27, 2023

Fix #14

@irevoire irevoire force-pushed the start-documenting-deserr branch from 8ba9c58 to 65bdbf5 Compare January 28, 2023 01:02
Copy link

@dureuill dureuill left a 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

Copy link
Contributor

@loiclec loiclec left a 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,
))
}
Copy link
Contributor

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?

Copy link
Contributor Author

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

@irevoire irevoire requested review from dureuill and loiclec January 31, 2023 15:14
Copy link

@dureuill dureuill left a 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)

@irevoire irevoire force-pushed the start-documenting-deserr branch 2 times, most recently from 6c2e1d8 to 9682afb Compare January 31, 2023 18:48
Copy link
Contributor

@loiclec loiclec left a 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:

deserr offers a derive proc macro to automatically implement Deserr for your types. However, unlike serde, it is also very easy to implement these traits manually. See <this file/folder> etc...

Comment on lines +272 to +377
assert_eq!(err.to_string(), "Unknown field `doggo`: expected one of `query`");
```
Copy link
Contributor

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 | |
Copy link
Contributor

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.

Copy link
Contributor Author

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?

@irevoire irevoire force-pushed the start-documenting-deserr branch from 9682afb to 2531096 Compare February 1, 2023 11:16
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
@irevoire irevoire force-pushed the start-documenting-deserr branch from 3a1f08c to e4c1a62 Compare February 1, 2023 15:42
@irevoire irevoire requested a review from loiclec February 1, 2023 15:54
@irevoire irevoire merged commit 59ce7cc into main Feb 7, 2023
@irevoire irevoire deleted the start-documenting-deserr branch February 7, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document all the attributes of the macro

5 participants