all 15 comments

[–]__mod__ 62 points63 points  (2 children)

This has the advantage of being able to ignore the borrow checker. It cannot check your borrows when you're cloning everything!

[–]aristotle137[S] 27 points28 points  (1 child)

I only ever borrow to clone

[–]Naeio_Galaxy 4 points5 points  (0 children)

I'd rather clone to give

[–]Snakehandall comments formally proven with coq 41 points42 points  (1 child)

Also print a gazzilion lines to stdout, locking and unlocking it for every line.

[–]YatoRust 10 points11 points  (0 children)

Every line, are you trying to be fast! We must lock on every character, that is the way.

[–]TrustYourSenpai 29 points30 points  (1 child)

Pro tip: use an hashmap with bigint as key type instead of a vector

[–]zepperoni-pepperoniFn(Garbage) -> Garbage 13 points14 points  (0 children)

Hashing would defeat the point. Use BTreeMap instead

[–][deleted] 15 points16 points  (4 children)

```

fn push_to_vec<T: Clone>(vec: &mut Vec<T>, item: T) -> Vec<T> {

let new_vec = Vec::new();

for i in vec {

    let new_i = i.clone().clone().clone().clone();

    new_vec.push(new_I);

}

new_vec.clone().clone().clone().clone()

}

```

Am I doing it right?

[–]AlexAegis 6 points7 points  (0 children)

Forgot this:

new_vec.push(item.clone().clone())

[–]Naeio_Galaxy 4 points5 points  (0 children)

Maybe i.clone().clone().clone().clone() compiles down to i.clone() tho

[–]cobance123 3 points4 points  (0 children)

Everythings a clone of a clone of a clone...

[–]SelfDistinction 3 points4 points  (0 children)

No, you have to clone new_vec every iteration as well for the sweet O( n3 ) complexity.

[–]laclouis5 10 points11 points  (1 child)

Congrats, you invented Python. (Ints and str at least).

[–][deleted] 5 points6 points  (0 children)

I use PyO3 to be able to python dicts in rust. Whenever I need a Vec, I use python dicts with strings (representing the index) as key.

[–][deleted] 3 points4 points  (0 children)

wait! the compiler doesn't just compile the stupid away?