-
Notifications
You must be signed in to change notification settings - Fork 1
Fix some clippy warnings #34
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
base: master
Are you sure you want to change the base?
Conversation
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.
Nice new clippy lints they've added 👏
I'm glad my project came in handy for you and thanks for taking the time to open this PR. Generally it's looking good. Just some minor comments.
@@ -104,7 +104,7 @@ pub enum Neo4jError { | |||
/// * the server returns an error. | |||
#[error("{error}")] | |||
#[non_exhaustive] | |||
ServerError { error: ServerError }, | |||
ServerError { error: Box<ServerError> }, |
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.
Since this is a user-facing (and breaking) API change, can you please add an entry to CHANGELOG.md
? I suggest to classify this under "Improvements" and please also add the "
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.
Also, this section of CONTRIBUTING.md
might be relevant as well since you're changing the public API.
neo4j/src/error_.rs
Outdated
@@ -55,7 +55,7 @@ type BoxError = Box<dyn StdError + Send + Sync>; | |||
/// the server version. | |||
pub enum Neo4jError { | |||
/// used when | |||
/// * experiencing a connectivity error. | |||
/// * experiencing a connectivity error. |
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.
/// * experiencing a connectivity error. | |
/// * experiencing a connectivity error. |
Please don't remove the line breaks from the markdown docs 😇 There more places like this in the PR. I spare you repeating this comment there.
Done. I've added a line on the CHANGELOG.md and removed all the whitespace changes. |
The servererror variant of neo4jerror is huge. on my computer it is 184 bytes. clippy warns us that it's not recommended to have an err variant that big. the solution is to box the servererror, which requires a memory allocation, but reduces the size of the result. this way, we won't need to reserve that much stack space for every result. errors are less common to occur, so the benefit of reducing the size of all results should compensate for the memory allocation required in case of a servererror. see the details of this lint on the link below: https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err>
The RecordBuffer::Transaction variant is empty. Clippy suggests removing the struct pattern `{..}`.
Instead of using the format! macro, which creates a string, feed the format directly to the trace! and debug! macros. This achieves the same result, without creating an intermediate String.
Hello. When building this crate clippy emits some warnings.
One of them is about the size of the
neo4j::Result
type.Neo4jError has a
ServerError
variant that takes up a lot of space. This forces all Neo4jErrors, and thusall
neo4j::Result
s to be huge, which can impact performance.The suggested solution is to wrap the
ServerError
on aBox
. This reduces the size of aNeo4jError
from 184 bytes to 40 bytes (on my computer).The other warnings were less important. Two of them were more of a style lint, the other was about an
unnecessary use of the format! macro.
P.D: This crate is amazing. I've used it for a school project, thank you!! :)