-
Notifications
You must be signed in to change notification settings - Fork 180
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
Remove Yokeable::Output from ZeroCopyFrom trait #1499
Conversation
Without the YokeTraitHack, I was getting errors like
|
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.
lgtm, minor issue
@@ -61,8 +61,8 @@ impl Deref for LineBreakPropertyTable<'_> { | |||
} | |||
} | |||
|
|||
impl<'a> ZeroCopyFrom<LineBreakPropertyTable<'a>> for LineBreakPropertyTable<'static> { | |||
fn zero_copy_from<'b>(cart: &'b LineBreakPropertyTable<'a>) -> <Self as Yokeable<'b>>::Output { | |||
impl<'zcf> ZeroCopyFrom<'zcf, LineBreakPropertyTable<'_>> for LineBreakPropertyTable<'zcf> { |
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.
praise: good call on 'zcf
utils/yoke/derive/examples/derive.rs
Outdated
@@ -51,12 +51,12 @@ pub struct HasTuples<'data> { | |||
} | |||
|
|||
pub fn assert_zcf_tuples<'b, 'data>(x: &'b HasTuples<'data>) -> HasTuples<'b> { | |||
HasTuples::<'static>::zero_copy_from(x) | |||
HasTuples::<'b>::zero_copy_from(x) |
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.
question: is this explicit lt still necessary? one of the benefits of the simplification is that a bunch of these won't be needed anymore
utils/zerovec/src/yoke_impls.rs
Outdated
for<'b> Yokeable<'b, Output = <K as ZeroMapKV<'b>>::Container>, | ||
<V as ZeroMapKV<'static>>::Container: | ||
for<'b> Yokeable<'b, Output = <V as ZeroMapKV<'b>>::Container>, | ||
<K as ZeroMapKV<'a>>::Container: ZeroCopyFrom<'a, <K as ZeroMapKV<'s>>::Container>, |
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.
thought: ah, these bounds get much simpler, i was hoping this would be the case
@@ -61,31 +62,42 @@ use stable_deref_trait::StableDeref; | |||
/// } | |||
/// | |||
/// // Reference from a borrowed version of self | |||
/// impl<'data> ZeroCopyFrom<MyStruct<'data>> for MyStruct<'static> { | |||
/// fn zero_copy_from<'b>(cart: &'b MyStruct<'data>) -> MyStruct<'b> { | |||
/// impl<'zcf> ZeroCopyFrom<'zcf, MyStruct<'_>> for MyStruct<'zcf> { |
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.
nit: the yokeable impl is no longer necessary in the docs above
utils/zerovec/src/yoke_impls.rs
Outdated
impl<'a, T: 'static + AsULE + ?Sized> ZeroCopyFrom<'a, ZeroVec<'_, T>> for ZeroVec<'a, T> { | ||
impl<'zcf, T> ZeroCopyFrom<'zcf, ZeroVec<'_, T>> for ZeroVec<'zcf, T> | ||
where | ||
T: 'zcf + AsULE + ?Sized, |
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.
issue: not sure if T: 'zcf
makes sense here, but aiui it doesn't cause harm to have
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.
We need either T: 'zcf
or T: 'static
to make the compiler happy when compiling ZeroVec<'zcf, T>
, so I figured we should use the less restrictive lifetime.
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.
Yeah, I think it should be 'static
for now, because a non-'static
AsULE doesn't quite make sense (.get()
can't work), and it seems misleading to have a 'zcf
bound that isn't actually useful.
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.
ok, done.
utils/zerovec/src/yoke_impls.rs
Outdated
V: 'static + for<'b> ZeroMapKV<'b> + ?Sized, | ||
<K as ZeroMapKV<'a>>::Container: ZeroCopyFrom<'a, <K as ZeroMapKV<'s>>::Container>, | ||
<V as ZeroMapKV<'a>>::Container: ZeroCopyFrom<'a, <V as ZeroMapKV<'s>>::Container>, | ||
K: 'zcf + for<'b> ZeroMapKV<'b> + ?Sized, |
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.
ditto: does the 'zcf
bound actually get us anything?
Fixes #1255
Replaces #1257
Using this trait:
And this function signature:
I managed to get this to compile: