Thinking of Identities without Copy trait as non-owning?

⚓ rust    📅 2025-05-15    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 46 days ago. The information described in this article may have changed.

Take this example:

fn main() {
let v: Vec<i32> = vec![0, 1, 2];
let n_ref: &i32 = &v[0];
let n: i32 = *n_ref;
}

Here the code passes compiler checks, but it won't for Strings.

For strings do not implement Copy.

Wouldn't it be a useful shorthand to simply not think of ownership for variables that have a Copy trait? (Since they are never moved.)

12 posts - 5 participants

Read full topic

🏷️ rust_feed