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

Value returned by `to_owned` doesn't always *own* the data #48876

Open
BusyJay opened this Issue Mar 9, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@BusyJay
Copy link

BusyJay commented Mar 9, 2018

For example:

let a = vec![1, 2];
let s = Some(&a);
let r = vec![];
if let Some(ref v) = s {
    r = v.to_owned();
}

This doesn't compile:

error[E0308]: mismatched types
 --> src/main.rs:6:13
  |
6 |         r = v.to_owned();
  |             ^^^^^^^^^^^^ expected struct `std::vec::Vec`, found reference
  |
  = note: expected type `std::vec::Vec<_>`
             found type `&std::vec::Vec<{integer}>`

Relates to #43236.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.