messing around with borrowing and mutability
This commit is contained in:
parent
7402a7ec82
commit
c5ebaa16dd
22
src/main.rs
22
src/main.rs
|
@ -1,13 +1,13 @@
|
|||
#[derive(Debug)]
|
||||
struct Point(i32, i32);
|
||||
|
||||
fn add(p1: &Point, p2: &Point) -> Point {
|
||||
return Point(p1.0 + p2.0, p1.1 + p2.1);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let p1 = Point(3, 4);
|
||||
let p2 = Point(10, 20);
|
||||
let p3 = add(&p1, &p2);
|
||||
println!("{p1:?} + {p2:?} = {p3:?}");
|
||||
let mut a: i32 = 10;
|
||||
let mut b: &mut i32 = &mut a;
|
||||
|
||||
{
|
||||
let c: &mut i32 = &mut b;
|
||||
*c = 20;
|
||||
println!("c: {c}");
|
||||
}
|
||||
|
||||
println!("a: {a}");
|
||||
//println!("b: {b}");
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"rustc_fingerprint":16320356917333427825,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.66.1 (90743e729 2023-01-10)\nbinary: rustc\ncommit-hash: 90743e7298aca107ddaa0c202a4d3604e29bfeb6\ncommit-date: 2023-01-10\nhost: x86_64-unknown-linux-gnu\nrelease: 1.66.1\nLLVM version: 15.0.2\n","stderr":""},"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/vbatts/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"15697416045686424142":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n","stderr":""}},"successes":{}}
|
||||
{"rustc_fingerprint":16320356917333427825,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.66.1 (90743e729 2023-01-10)\nbinary: rustc\ncommit-hash: 90743e7298aca107ddaa0c202a4d3604e29bfeb6\ncommit-date: 2023-01-10\nhost: x86_64-unknown-linux-gnu\nrelease: 1.66.1\nLLVM version: 15.0.2\n","stderr":""},"15697416045686424142":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n","stderr":""},"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/vbatts/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}
|
|
@ -0,0 +1 @@
|
|||
{"rustc":7419878829587384386,"features":"[]","target":14602933489408981941,"profile":7309141686862299243,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/basics00-2aafd7e9003de7a7/dep-bin-basics00"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
This file has an mtime of when this was started.
|
File diff suppressed because one or more lines are too long
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
This file has an mtime of when this was started.
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
{"rustc":7419878829587384386,"features":"[]","target":14602933489408981941,"profile":1021633075455700787,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/basics00-3922c6fa78ff0509/dep-test-bin-basics00"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
|
Binary file not shown.
|
@ -0,0 +1,5 @@
|
|||
/home/vbatts/tmp.rust/basics00/target/debug/deps/basics00-2aafd7e9003de7a7.rmeta: src/main.rs
|
||||
|
||||
/home/vbatts/tmp.rust/basics00/target/debug/deps/basics00-2aafd7e9003de7a7.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
|
@ -0,0 +1,5 @@
|
|||
/home/vbatts/tmp.rust/basics00/target/debug/deps/basics00-3922c6fa78ff0509.rmeta: src/main.rs
|
||||
|
||||
/home/vbatts/tmp.rust/basics00/target/debug/deps/basics00-3922c6fa78ff0509.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
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…
Reference in New Issue