Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Generic-swap/Rust/generic-swap-1.rust
Normal file
3
Task/Generic-swap/Rust/generic-swap-1.rust
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn generic_swap<'a, T>(var1: &'a mut T, var2: &'a mut T) {
|
||||
std::mem::swap(var1, var2)
|
||||
}
|
||||
12
Task/Generic-swap/Rust/generic-swap-2.rust
Normal file
12
Task/Generic-swap/Rust/generic-swap-2.rust
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
fn main() {
|
||||
let mut a: String = "Alice".to_owned();
|
||||
let mut b: String = "Bob".to_owned();
|
||||
let mut c: i32 = 1;
|
||||
let mut d: i32 = 2;
|
||||
|
||||
generic_swap(&mut a, &mut b);
|
||||
generic_swap(&mut c, &mut d);
|
||||
|
||||
println!("a={}, b={}", a, b);
|
||||
println!("c={}, d={}", c, d);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue