immutable slice and borrowed slice
This commit is contained in:
parent
de5218c5dd
commit
4518c489dc
50 changed files with 7 additions and 28 deletions
29
src/main.rs
29
src/main.rs
|
@ -1,26 +1,9 @@
|
|||
fn main() {
|
||||
let mut a: [i8; 10] = [42; 10];
|
||||
a[5] = 0;
|
||||
println!("a: {:?}", a);
|
||||
let a: [i32; 6] = [10, 20, 30, 40, 50, 60];
|
||||
println!("a: {a:?}");
|
||||
|
||||
// so this is assigning an immutable tuple
|
||||
let t: (i8, bool) = (7, true);
|
||||
println!("t 1st: {}", t.0);
|
||||
println!("t 2nd: {}", t.1);
|
||||
|
||||
let pre_ref_x: &mut i32;
|
||||
{
|
||||
let mut x: i32 = 10;
|
||||
let mut z: i32 = 5;
|
||||
println!("x: {x}");
|
||||
println!("z: {z}");
|
||||
let mut ref_x: &mut i32 = &mut x;
|
||||
*ref_x = 20;
|
||||
pre_ref_x = &mut x;
|
||||
println!("x: {x}");
|
||||
ref_x = &mut z;
|
||||
*ref_x = 20;
|
||||
println!("z: {z}");
|
||||
}
|
||||
println!("pre_ref_x: {pre_ref_x}");
|
||||
let s: &[i32] = &a[2..4];
|
||||
println!("s: {s:?}");
|
||||
println!("a[2]: {}", a[2]);
|
||||
println!("s[0]: {}", s[0]);
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
7cbe46f1ccde8504
|
File diff suppressed because one or more lines are too long
Binary file not shown.
BIN
target/debug/deps/basics00-837a95fe33c7c079
Executable file
BIN
target/debug/deps/basics00-837a95fe33c7c079
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue