Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let mut v = vec![1,2,3,4,5];
- v = vec_swap(v);
- v[0] = 55;
- println!("{:?}", v);
- }
- fn vec_swap<T: Copy>(mut v: Vec<T>) -> Vec<T> {
- if v.len() >= 2 {
- let tmp = v[0];
- v[0] = v[1];
- v[1] = tmp;
- }
- v
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement