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

RUST-1358 Remove most type constraints on cursor values #891

Merged
merged 2 commits into from
Jun 13, 2023

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Jun 8, 2023

RUST-1358

Now that we're internally passing around RawDocument rather than the deserialized type, we don't need to carry around the final type for our internal cursor implementation bits, and in turn we don't need the Sync + Send + Unpin constraints on that type.

I think there's further opportunity for cleaning up the implementation, but that won't have any user-facing benefit, so I've filed RUST-1676 to track that.

@abr-egn abr-egn requested a review from isabelatkinson June 8, 2023 15:04
Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

looks good, just one question!

drop_address: Option<ServerAddress>,
#[cfg(test)]
kill_watcher: Option<oneshot::Sender<()>>,
_phantom: std::marker::PhantomData<T>,
_phantom: std::marker::PhantomData<fn() -> T>,
Copy link
Contributor

Choose a reason for hiding this comment

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

out of curiosity, why was this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a gnarly little corner of the Rust typesystem: https://doc.rust-lang.org/nomicon/phantom-data.html

TL;DR changing it from PhantomData<T> to PhantomData<fn() -> T> means the compiler will no longer consider dropping Cursor<T> to drop a T, which can relax restrictions in some hypothetical situations.

@abr-egn abr-egn merged commit e71aa72 into mongodb:main Jun 13, 2023
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.

2 participants