Prechádzať zdrojové kódy

Vector2 Crate implemented

Ali Hirschmann 5 rokov pred
rodič
commit
0a1fc1737e
30 zmenil súbory, kde vykonal 65 pridanie a 0 odobranie
  1. 7 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 6 0
      vector2/Cargo.lock
  4. 9 0
      vector2/Cargo.toml
  5. 30 0
      vector2/src/lib.rs
  6. 1 0
      vector2/target/.rustc_info.json
  7. 0 0
      vector2/target/debug/.cargo-lock
  8. BIN
      vector2/target/debug/.fingerprint/vector2-eb21d1e2ed3d089b/dep-lib-vector2-eb21d1e2ed3d089b
  9. 1 0
      vector2/target/debug/.fingerprint/vector2-eb21d1e2ed3d089b/invoked.timestamp
  10. 1 0
      vector2/target/debug/.fingerprint/vector2-eb21d1e2ed3d089b/lib-vector2-eb21d1e2ed3d089b
  11. 1 0
      vector2/target/debug/.fingerprint/vector2-eb21d1e2ed3d089b/lib-vector2-eb21d1e2ed3d089b.json
  12. BIN
      vector2/target/debug/deps/libvector2-eb21d1e2ed3d089b.rlib
  13. BIN
      vector2/target/debug/deps/libvector2-eb21d1e2ed3d089b.rmeta
  14. 7 0
      vector2/target/debug/deps/vector2-eb21d1e2ed3d089b.d
  15. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/13oek0ob5uokyoj2.bc.z
  16. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/13oek0ob5uokyoj2.o
  17. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/2nrbu02wvdk7cwdj.bc.z
  18. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/2nrbu02wvdk7cwdj.o
  19. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/3kl88nbd5ux7skke.bc.z
  20. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/3kl88nbd5ux7skke.o
  21. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/4vwgujkkc5ppgxjk.bc.z
  22. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/4vwgujkkc5ppgxjk.o
  23. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/dep-graph.bin
  24. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/query-cache.bin
  25. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/tdz6dag8nduqg7g.bc.z
  26. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/tdz6dag8nduqg7g.o
  27. BIN
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/work-products.bin
  28. 0 0
      vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a.lock
  29. 1 0
      vector2/target/debug/libvector2.d
  30. BIN
      vector2/target/debug/libvector2.rlib

+ 7 - 0
Cargo.lock

@@ -3,4 +3,11 @@
 [[package]]
 name = "aoc19"
 version = "0.1.0"
+dependencies = [
+ "vector2 0.1.0",
+]
+
+[[package]]
+name = "vector2"
+version = "0.1.0"
 

+ 1 - 0
Cargo.toml

@@ -7,3 +7,4 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
+vector2 = { path = "./vector2/" }

+ 6 - 0
vector2/Cargo.lock

@@ -0,0 +1,6 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "vector2"
+version = "0.1.0"
+

+ 9 - 0
vector2/Cargo.toml

@@ -0,0 +1,9 @@
+[package]
+name = "vector2"
+version = "0.1.0"
+authors = ["Ali Hirschmann <lisabel.hirschmann@king.com>"]
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]

+ 30 - 0
vector2/src/lib.rs

@@ -0,0 +1,30 @@
+#[derive(Hash, Eq, PartialEq, Debug, Clone)]
+pub struct Vector2 {
+    pub x: i32,
+    pub y: i32,
+}
+//Implement vector 2 functions
+impl Vector2 {   
+
+    pub fn right() -> Vector2 {
+        Vector2{x:1, y:0}
+    }
+    pub fn left() -> Vector2 {
+        Vector2{x:-1, y:0}
+    }
+    pub fn up() -> Vector2 {
+        Vector2{x:0, y:1}
+    }
+    pub fn down() -> Vector2 {
+        Vector2{x:0, y:-1}
+    }
+    pub fn zero() -> Vector2 {
+        Vector2{x:0, y:0}
+    }
+    pub fn add(&self, other: &Self) -> Vector2 {
+        Vector2{x: self.x + other.x, y: self.y + other.y}
+    }
+    pub fn distance(&self, to: &Self) -> i32{
+        ((to.x - self.x.abs()) + (to.y - self.y.abs()))
+    }
+}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 0
vector2/target/.rustc_info.json


+ 0 - 0
vector2/target/debug/.cargo-lock


BIN
vector2/target/debug/.fingerprint/vector2-eb21d1e2ed3d089b/dep-lib-vector2-eb21d1e2ed3d089b


+ 1 - 0
vector2/target/debug/.fingerprint/vector2-eb21d1e2ed3d089b/invoked.timestamp

@@ -0,0 +1 @@
+This file has an mtime of when this was started.

+ 1 - 0
vector2/target/debug/.fingerprint/vector2-eb21d1e2ed3d089b/lib-vector2-eb21d1e2ed3d089b

@@ -0,0 +1 @@
+c6a79abb867af4be

+ 1 - 0
vector2/target/debug/.fingerprint/vector2-eb21d1e2ed3d089b/lib-vector2-eb21d1e2ed3d089b.json

@@ -0,0 +1 @@
+{"rustc":15724114188122511087,"features":"[]","target":2019065333103227819,"profile":14996655781355331481,"path":10872709659218687626,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug\\.fingerprint\\vector2-eb21d1e2ed3d089b\\dep-lib-vector2-eb21d1e2ed3d089b"}}],"rustflags":[],"metadata":16502443333231043903}

BIN
vector2/target/debug/deps/libvector2-eb21d1e2ed3d089b.rlib


BIN
vector2/target/debug/deps/libvector2-eb21d1e2ed3d089b.rmeta


+ 7 - 0
vector2/target/debug/deps/vector2-eb21d1e2ed3d089b.d

@@ -0,0 +1,7 @@
+C:\Users\lisabel.hirschmann\king-repos\aoc19\vector2\target\debug\deps\vector2-eb21d1e2ed3d089b.rmeta: src\lib.rs
+
+C:\Users\lisabel.hirschmann\king-repos\aoc19\vector2\target\debug\deps\libvector2-eb21d1e2ed3d089b.rlib: src\lib.rs
+
+C:\Users\lisabel.hirschmann\king-repos\aoc19\vector2\target\debug\deps\vector2-eb21d1e2ed3d089b.d: src\lib.rs
+
+src\lib.rs:

BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/13oek0ob5uokyoj2.bc.z


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/13oek0ob5uokyoj2.o


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/2nrbu02wvdk7cwdj.bc.z


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/2nrbu02wvdk7cwdj.o


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/3kl88nbd5ux7skke.bc.z


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/3kl88nbd5ux7skke.o


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/4vwgujkkc5ppgxjk.bc.z


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/4vwgujkkc5ppgxjk.o


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/dep-graph.bin


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/query-cache.bin


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/tdz6dag8nduqg7g.bc.z


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/tdz6dag8nduqg7g.o


BIN
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a-working/work-products.bin


+ 0 - 0
vector2/target/debug/incremental/vector2-1l0a4bmgixm7g/s-fij58j9upo-3i202a.lock


+ 1 - 0
vector2/target/debug/libvector2.d

@@ -0,0 +1 @@
+C:\Users\lisabel.hirschmann\king-repos\aoc19\vector2\target\debug\libvector2.rlib: C:\Users\lisabel.hirschmann\king-repos\aoc19\vector2\src\lib.rs

BIN
vector2/target/debug/libvector2.rlib