Skip to content
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

feat(type): improve the Fields derive macro #14934

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge remote-tracking branch 'origin/main' into wrj/derive-fields
Signed-off-by: Runji Wang <wangrunji0408@163.com>
  • Loading branch information
wangrunji0408 committed Feb 5, 2024
commit 74cd28749e1fb566276ba3e65c01e95be513c568
7 changes: 7 additions & 0 deletions src/common/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,13 @@ pub trait ToOwnedDatum {
fn to_owned_datum(self) -> Datum;
}

impl ToOwnedDatum for &Datum {
#[inline(always)]
fn to_owned_datum(self) -> Datum {
self.clone()
}
}

impl<T: Into<ScalarImpl>> ToOwnedDatum for T {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'd prefer introducing a new trait for doing such conversion. By ToOwnedDatum I suppose it's only for the conversion from the ref type to an owned type, just like the std's ToOwned trait with GAT support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But logically types impl Into<ScalarImpl> can be converted ToOwnedDatum. I think it would be convenient to reuse this trait.

#[inline(always)]
fn to_owned_datum(self) -> Datum {
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.