-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Avoid Pin by using a trait object suffix for Request #3
base: master
Are you sure you want to change the base?
Conversation
where | ||
R: ?Sized + private::Response, | ||
{ | ||
marker: PhantomData<&'a ()>, |
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.
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>> { |
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.
I wonder if you'd maybe want to make this Request<'static, Option<T>>
?
So I came up with a way to write |
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.