Skip to content
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

There should be an impl<T> AsMut<[T]> for Vec<T>. #28549

Closed
dwrensha opened this issue Sep 20, 2015 · 3 comments
Closed

There should be an impl<T> AsMut<[T]> for Vec<T>. #28549

dwrensha opened this issue Sep 20, 2015 · 3 comments

Comments

@dwrensha
Copy link
Contributor

In GJ I have this trait like this:

pub trait AsyncRead: 'static {
    fn try_read<T>(self, buf: T, min_bytes: usize) -> Promise<(Self, T, usize), Error<(Self, T)>> where T: DerefMut<Target=[u8]>, Self: Sized;
}

I'd like to switch the bound on T to be T: AsMut<[u8]>, but then I can no longer use a bare Vec<u8> for T, because there is currently no impl<T> AsMut<[T]> for Vec<T>.

It seems to me that such an impl ought to exist, especially because impl<T> AsRef<[T]> for Vec<T> already exists.

@bluss
Copy link
Member

bluss commented Sep 20, 2015

Yes, and Box<[T]>.

bluss added a commit to bluss/rust that referenced this issue Sep 25, 2015
bors added a commit that referenced this issue Sep 27, 2015
@bluss
Copy link
Member

bluss commented Sep 27, 2015

Since it landed now, it should appear first in Rust 1.5 (and will be stable).

@dwrensha
Copy link
Contributor Author

Thank you!

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

No branches or pull requests

3 participants