You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
n owned_iterator(slice: &[~str]) -> ~Iterator<~str> {
~slice.iter().map(|s| s.clone()) as ~Iterator<~str>
}
fn main() {
let mut fail = {
owned_iterator(~["ok".to_owned()])
};
let v = ~["fail".to_owned()];
for i in fail {
println!("{}", i); // prints "fail"
}
let mut segFault = {
owned_iterator(~["ok".to_owned()])
};
let v = ~[-1];
for i in segFault {
println!("{}", i); // Segmentation fault
}
}
The text was updated successfully, but these errors were encountered:
This bug was originally reported on the Rust subreddit by user
double_to_bool_conv
: http://www.reddit.com/r/rust/comments/24kfmv/iterator_can_live_longer_than_its_parent_is_this/The version below has been updated after the removal of the
~"string"
syntax.The text was updated successfully, but these errors were encountered: