Skip to content

Avoid Pin by using a trait object suffix for Request #3

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mystor
Copy link
Owner

@mystor mystor commented Aug 25, 2020

This simplifies the callsites significantly, as the parameter type is now a simpler &mut Request<'a> type, and reduces the amount of unsafe code which is necessary.

where
R: ?Sized + private::Response,
{
marker: PhantomData<&'a ()>,
Copy link

Choose a reason for hiding this comment

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

I was worried about this not being invariant, but... &mut Request<'a> is invariant over 'a because of the &mut, as it's basically a &mut (TypeId, Option<&'a T>) for some unknown T, so it has to be invariant to avoid allowing writing in a shorter lifetime.

src/lib.rs Outdated
_marker: PhantomData,
},
value: None,
impl<T: 'static> Request<'_, Option<T>> {
Copy link

Choose a reason for hiding this comment

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

I wonder if you'd maybe want to make this Request<'static, Option<T>>?

@eddyb
Copy link

eddyb commented Aug 25, 2020

So I came up with a way to write Request<T> instead of Request<Option<T>> (since you made it part of the public API), but hit a missing normalization in rustc, which I've filed as rust-lang/rust#75899.

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