-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
chore: lots of lints and fixes #1523
Conversation
This is #1414 |
No rustfmt? Be aware this repo has a rustfmt.toml. |
pgrx/src/datum/date.rs
Outdated
let month: i32 = month.into(); | ||
let day: i32 = day.into(); |
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.
These implementations existing are simply incorrect, do not use them.
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.
would it make sense to perhaps implement into()
as try_into().unwrap()
? In that case it would be consistent, and can be replaced.
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.
Essentially none of the datetime types should actually implement From, even if they currently do, which is why so many dicey implementations and use of try_into()
everywhere. I have to create more tests to verify the correctness of their implementations, and any change which removes these is breaking API, and the lifetimes problem has distracted me, which is also why I haven't shipped more of them:
Thx for the feedback, addressed most of it in 582a0ac. Does it look better now? |
8a8f670
to
c185112
Compare
not sure what you mean - |
I dunno, wasn't sure if it was simple omission or tooling or what. |
027ec3d
to
366fb0b
Compare
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.
Looks good, will doublecheck to see if it still looks good when I wake up.
Ah, this had conflicts with #1468, sorry! |
rebasing... |
* it is an anti-pattern for a fn to take a reference, and clone it right away. If a fn needs to own a value, a value ownership should be passed in, not cloned inside the fn. This way the caller can decide to clone something, or to pass it in as is * use `&Path` instead of `&PathBuf` (same as &str instead of &String) * use `.cmp` for comparison * some spelling * remove some unneeded lifetimes * lots of `try_into` can be replaced with `into` * lots of `match` statements can be simplified * use `.is_null()` instead of comparing with the null ptr * do not impl `ToString` trait, use `Display` instead, and get ToString for free - perf gain too. TODO: * there was a typo in `pgrx/src/datum/datetime_support/ctor.rs` - incorrectly declared conditional compilation for `fn date_bin`. Fixing it does not compile. * `pgrx/src/spi/tuple.rs` has an incorrect double-usize casting, one should be removed, but it seems like it was a bug
Co-authored-by: Jubilee <[email protected]>
seems to be passing ок |
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, still looks good!
&Path
instead of&PathBuf
(same as &str instead of &String).cmp
for comparisonmatch
statements can be simplified.is_null()
instead of comparing with the null ptrToString
trait, useDisplay
instead, and get ToString for free - perf gain too.