diff options
27 files changed, 48 insertions, 20 deletions
diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/Cargo.lock b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/Cargo.lock deleted file mode 100644 index 22aba19..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "method" -version = "0.1.0" diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/.rustc_info.json b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/.rustc_info.json deleted file mode 100644 index 9683918..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/.rustc_info.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc_fingerprint":1612890582466578081,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.66.0 (69f9c33d7 2022-12-12) (Arch Linux rust 1:1.66.0-1)\nbinary: rustc\ncommit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943\ncommit-date: 2022-12-12\nhost: x86_64-unknown-linux-gnu\nrelease: 1.66.0\nLLVM version: 14.0.6\n","stderr":""},"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/usr\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":{}}
\ No newline at end of file diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/CACHEDIR.TAG b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/CACHEDIR.TAG deleted file mode 100644 index 20d7c31..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/CACHEDIR.TAG +++ /dev/null @@ -1,3 +0,0 @@ -Signature: 8a477f597d28d172789f06886806bc55 -# This file is a cache directory tag created by cargo. -# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.cargo-lock b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.cargo-lock deleted file mode 100644 index e69de29..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.cargo-lock +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/bin-method b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/bin-method deleted file mode 100644 index ca86b33..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/bin-method +++ /dev/null @@ -1 +0,0 @@ -a691507414a49bcb
\ No newline at end of file diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/bin-method.json b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/bin-method.json deleted file mode 100644 index b82a846..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/bin-method.json +++ /dev/null @@ -1 +0,0 @@ -{"rustc":9725468309624180303,"features":"[]","target":16139928211081419303,"profile":9251013656241001069,"path":1684066648322511884,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/method-e10ed74834842a40/dep-bin-method"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0}
\ No newline at end of file diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/dep-bin-method b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/dep-bin-method Binary files differdeleted file mode 100644 index 5fdf103..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/dep-bin-method +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/invoked.timestamp b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/invoked.timestamp deleted file mode 100644 index e00328d..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/.fingerprint/method-e10ed74834842a40/invoked.timestamp +++ /dev/null @@ -1 +0,0 @@ -This file has an mtime of when this was started.
\ No newline at end of file diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/deps/method-e10ed74834842a40 b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/deps/method-e10ed74834842a40 Binary files differdeleted file mode 100755 index bfb8755..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/deps/method-e10ed74834842a40 +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/deps/method-e10ed74834842a40.d b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/deps/method-e10ed74834842a40.d deleted file mode 100644 index 1afe682..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/deps/method-e10ed74834842a40.d +++ /dev/null @@ -1,5 +0,0 @@ -/home/pico/codes/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/deps/method-e10ed74834842a40: src/main.rs - -/home/pico/codes/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/deps/method-e10ed74834842a40.d: src/main.rs - -src/main.rs: diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/1inymij3x0ch8pp9.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/1inymij3x0ch8pp9.o Binary files differdeleted file mode 100644 index ffe9181..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/1inymij3x0ch8pp9.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/1sqvtoy8vtz4m0un.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/1sqvtoy8vtz4m0un.o Binary files differdeleted file mode 100644 index 09a1dcc..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/1sqvtoy8vtz4m0un.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/28emacl7u7q0r5nb.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/28emacl7u7q0r5nb.o Binary files differdeleted file mode 100644 index 76fbefc..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/28emacl7u7q0r5nb.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/36unv514f6f2demr.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/36unv514f6f2demr.o Binary files differdeleted file mode 100644 index 9bcceb5..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/36unv514f6f2demr.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/3bcq9wv5zzh54w12.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/3bcq9wv5zzh54w12.o Binary files differdeleted file mode 100644 index 8d9a07c..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/3bcq9wv5zzh54w12.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/410pp0jbv822jtw3.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/410pp0jbv822jtw3.o Binary files differdeleted file mode 100644 index 1ba92fb..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/410pp0jbv822jtw3.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/5827txjlbzheowls.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/5827txjlbzheowls.o Binary files differdeleted file mode 100644 index 4e019e2..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/5827txjlbzheowls.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/9pemqmha9q3j8ep.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/9pemqmha9q3j8ep.o Binary files differdeleted file mode 100644 index f29e949..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/9pemqmha9q3j8ep.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/dep-graph.bin b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/dep-graph.bin Binary files differdeleted file mode 100644 index 2117b19..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/dep-graph.bin +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/oa7vpy4no3g983a.o b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/oa7vpy4no3g983a.o Binary files differdeleted file mode 100644 index b01ca06..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/oa7vpy4no3g983a.o +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/query-cache.bin b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/query-cache.bin Binary files differdeleted file mode 100644 index cbb28b3..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/query-cache.bin +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/work-products.bin b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/work-products.bin Binary files differdeleted file mode 100644 index d850296..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv-81g99pd4npj0/work-products.bin +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv.lock b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv.lock deleted file mode 100644 index e69de29..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/incremental/method-wj4k1j5le4zj/s-gglwdrqqt3-1p0l5fv.lock +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/method b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/method Binary files differdeleted file mode 100755 index bfb8755..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/method +++ /dev/null diff --git a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/method.d b/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/method.d deleted file mode 100644 index d1f2ab5..0000000 --- a/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/method.d +++ /dev/null @@ -1 +0,0 @@ -/home/pico/codes/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/target/debug/method: /home/pico/codes/rust/theBook/chapter-5-using-struct-to-structure-related-data/method/src/main.rs diff --git a/rust/theBook/chapter-6-enums-and-pattern-matching/enum-way/Cargo.toml b/rust/theBook/chapter-6-enums-and-pattern-matching/enum-way/Cargo.toml new file mode 100644 index 0000000..4e103bd --- /dev/null +++ b/rust/theBook/chapter-6-enums-and-pattern-matching/enum-way/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "enum-way" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/rust/theBook/chapter-6-enums-and-pattern-matching/enum-way/src/main.rs b/rust/theBook/chapter-6-enums-and-pattern-matching/enum-way/src/main.rs new file mode 100644 index 0000000..f419cc9 --- /dev/null +++ b/rust/theBook/chapter-6-enums-and-pattern-matching/enum-way/src/main.rs @@ -0,0 +1,40 @@ +#[derive(Debug)] + +enum UpState { + Alabama, + Alaska, +} + +enum Coin { + Penny, + Nickel, + Dime, + Quarter(UpState), +} + +fn main() { + let state = UpState::Alaska; + let coin = Coin::Quarter(state); + println!("the quater is {}",value_in_cents(coin)); + println!("x = {:?}", plus_one(None)); +} + +fn value_in_cents(coin: Coin) -> u8 { + match coin { + Coin::Penny => 1, + Coin::Nickel => 5, + Coin::Dime => 10, + Coin::Quarter(state) => { + println!("state quarter from {:?}",state); + 25 + } + } +} + + +fn plus_one(x: Option<i32>) -> Option<i32> { + match x { + None => None, + Some(i) => Some(i+1), + } +} |