-
Notifications
You must be signed in to change notification settings - Fork 183
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
Should we have FromVarULE? #1180
Comments
Yeah so I do want this, but my general thoughts are that this function will basically be called by users not the VZV/ZV APIs, so it's not important to have a trait for it unless we're doing a custom derive (which we should absolutely do eventually). My suggestion to Zibi for now was to implement this as an inherent method on the ULE type ( |
Would a method such as impl<'a, U> VarZeroVec<'a, U>
where
U: VarULE + ?Sized
{
fn get_decoded<T>(&'a self) -> Option<T>
where
T: FromVarULE<'a, U>
{
todo!()
}
} |
yes! it would need an
We can actually merge |
Would ZeroCopyFrom do the trick, instead of FromVarULE? |
Yes, I think so |
Though I think ZCF is a bit weird bc it requires Yokeable. I'll have to think about that |
FromVarULE is a special case of ZCF: the case when the source (the Yokeable) has no lifetime parameter. Let's not combine encode/decode like we did with the old AsVarULE. I prefer smaller traits when possible, and I think it results in a better outcome anyway. |
Nah, we need the lifetime parameter I think, and we also need the Yokeable. That's somewhat unfortunate but it is what it is. |
When we have GATs a lot of this should simplify, but that might be a ways off |
Discussion: add FromVarULE as its own trait for now, and see if we can unify it with ZeroCopyFrom later in #1186. |
Related: #1255 . If we can make that happen first then we won't need a separate trait |
Now that ZCF is simpler I think we should just use ZCF here. It might be worth having the proc macro autogen the impl if asked, though! |
I'm going to close this issue then |
Part of #1082
Split from #1179
If we want to support cases where the target type borrows from the VarULE,
FromVarULE
can work (playground):Thoughts? Needs input from:
The text was updated successfully, but these errors were encountered: