-
Notifications
You must be signed in to change notification settings - Fork 13k
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
&Box<[T]> does not impl IntoIterator #83589
Comments
You could say the same for We might also want owned |
I experimented with this locally. Fully-generic
I think downstream could only implement this if they have a local allocator type I tried
|
The same happens for use std::borrow::Cow;
fn one() {
let v = vec![1, 2, 3];
let c: Cow<'static, [u8]> = Cow::Owned(v);
for elem in &c {
println!("elem: {}", elem);
}
}
fn two() {
let v = vec![1, 2, 3];
let c: Cow<'_, [u8]> = Cow::Borrowed(v.as_slice());
for elem in &c {
println!("elem: {}", elem);
}
}
fn three() {
let v = vec![1, 2, 3];
let c: Cow<'static, [u8]> = Cow::Owned(v);
for elem in &*c {
println!("elem: {}", elem);
}
}
fn four() {
let v = vec![1, 2, 3];
let c: Cow<'_, [u8]> = Cow::Borrowed(v.as_slice());
for elem in &*c {
println!("elem: {}", elem);
}
}
|
I believe the |
I tried this code:
I expected to see this happen: I expected both functions
one
andtwo
to compile.Instead, this happened: function
one
does not compile:https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=93a16fe1e2860bd5eb98b2d73f00fc50
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: