-
Notifications
You must be signed in to change notification settings - Fork 58
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
Implement Borrow and BorrowMut for Matrix #14
Comments
Some issues with implementing AsRef/Borrow: impl<'a, T> AsRef<MatrixSlice<'a, T>> for Matrix<T> {
fn as_ref(&self) -> &MatrixSlice<'a, T> {
&self.as_slice()
}
}
impl<'a, T> AsMut<MatrixSliceMut<'a, T>> for Matrix<T> {
fn as_mut(&mut self) -> &mut MatrixSliceMut<'a, T> {
&self.as_mut_slice()
}
} This code fails to compile with the following errors:
But we cannot use an explicit lifetime as it goes against the trait:
Do you see anything obviously wrong with this approach @tafia ? If not I'd propose we make our own internal traits: pub trait AsSlice<T> where T: ?Sized {
fn as_slice(&self) -> T;
} (I haven't tested this yet). |
Sorry for the late answer. I think a more aggressive change of
|
I'm not sure that I entirely follow how this will solve the problem - but I look forward to seeing if you can pull it off! Let me know if I can (try to) help at all. |
It doesn't worked as well as I was expecting. |
I'm closing this issue. We wont be able to implement this in the way we want until Custom DSTs land. In which case we will not be implementing |
This is a mirror to rusty-machine/109.
The text was updated successfully, but these errors were encountered: