diff --git a/addr/Cargo.lock b/addr/Cargo.lock new file mode 100644 index 00000000..77292f61 --- /dev/null +++ b/addr/Cargo.lock @@ -0,0 +1,13 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "add-one" +version = "0.1.0" + +[[package]] +name = "adder" +version = "0.1.0" +dependencies = [ + "add-one 0.1.0", +] + diff --git a/addr/Cargo.toml b/addr/Cargo.toml new file mode 100644 index 00000000..d9380837 --- /dev/null +++ b/addr/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "adder", + "add-one", +] diff --git a/addr/add-one/.gitignore b/addr/add-one/.gitignore new file mode 100644 index 00000000..69369904 --- /dev/null +++ b/addr/add-one/.gitignore @@ -0,0 +1,3 @@ +/target +**/*.rs.bk +Cargo.lock diff --git a/addr/add-one/Cargo.toml b/addr/add-one/Cargo.toml new file mode 100644 index 00000000..03557910 --- /dev/null +++ b/addr/add-one/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "add-one" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/addr/add-one/src/lib.rs b/addr/add-one/src/lib.rs new file mode 100644 index 00000000..2397797a --- /dev/null +++ b/addr/add-one/src/lib.rs @@ -0,0 +1,11 @@ +pub fn add_one(x: i32) -> i32 { + x + 1 +} + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/addr/adder/.gitignore b/addr/adder/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/addr/adder/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/addr/adder/Cargo.toml b/addr/adder/Cargo.toml new file mode 100644 index 00000000..320c647c --- /dev/null +++ b/addr/adder/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "adder" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +add-one = {path = "../add-one"} diff --git a/addr/adder/src/main.rs b/addr/adder/src/main.rs new file mode 100644 index 00000000..c99ccf55 --- /dev/null +++ b/addr/adder/src/main.rs @@ -0,0 +1,8 @@ +use add_one; + +fn main() { + let num = 10; + let r = add_one::add_one(num); + println!("r === {}", r); + println!("Hello, world!"); +} diff --git a/addr/target/.rustc_info.json b/addr/target/.rustc_info.json new file mode 100644 index 00000000..96d9602e --- /dev/null +++ b/addr/target/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":17989264669760749350,"outputs":{"1164083562126845933":["rustc 1.38.0 (625451e37 2019-09-23)\nbinary: rustc\ncommit-hash: 625451e376bb2e5283fc4741caa0a3e8a2ca4d54\ncommit-date: 2019-09-23\nhost: x86_64-unknown-linux-gnu\nrelease: 1.38.0\nLLVM version: 9.0\n",""],"1138116330425514636":["___\n",""],"4476964694761187371":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/andy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\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_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"2196823701345282402":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/andy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\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_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""]},"successes":{}} \ No newline at end of file diff --git a/addr/target/debug/.cargo-lock b/addr/target/debug/.cargo-lock new file mode 100644 index 00000000..e69de29b diff --git a/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/dep-lib-add_one-f25b03445ef13e1f b/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/dep-lib-add_one-f25b03445ef13e1f new file mode 100644 index 00000000..2df294f8 Binary files /dev/null and b/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/dep-lib-add_one-f25b03445ef13e1f differ diff --git a/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/invoked.timestamp b/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/invoked.timestamp new file mode 100644 index 00000000..e00328da --- /dev/null +++ b/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/lib-add_one-f25b03445ef13e1f b/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/lib-add_one-f25b03445ef13e1f new file mode 100644 index 00000000..3e697fc1 --- /dev/null +++ b/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/lib-add_one-f25b03445ef13e1f @@ -0,0 +1 @@ +4691ba37eeb80a4a \ No newline at end of file diff --git a/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/lib-add_one-f25b03445ef13e1f.json b/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/lib-add_one-f25b03445ef13e1f.json new file mode 100644 index 00000000..ccbe1636 --- /dev/null +++ b/addr/target/debug/.fingerprint/add-one-f25b03445ef13e1f/lib-add_one-f25b03445ef13e1f.json @@ -0,0 +1 @@ +{"rustc":10683586082858123265,"features":"[]","target":3349314055383906947,"profile":14996655781355331481,"path":652465830340624038,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/add-one-f25b03445ef13e1f/dep-lib-add_one-f25b03445ef13e1f"}}],"rustflags":[],"metadata":15972075885573944569} \ No newline at end of file diff --git a/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/bin-adder-309a7669209f2ef8 b/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/bin-adder-309a7669209f2ef8 new file mode 100644 index 00000000..c83aff69 --- /dev/null +++ b/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/bin-adder-309a7669209f2ef8 @@ -0,0 +1 @@ +96d607c8f7968f34 \ No newline at end of file diff --git a/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/bin-adder-309a7669209f2ef8.json b/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/bin-adder-309a7669209f2ef8.json new file mode 100644 index 00000000..9584f76e --- /dev/null +++ b/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/bin-adder-309a7669209f2ef8.json @@ -0,0 +1 @@ +{"rustc":10683586082858123265,"features":"[]","target":9805538687745692616,"profile":14996655781355331481,"path":7714536825948459707,"deps":[[9496724924318511037,"add_one",false,5335280041850474822]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/adder-309a7669209f2ef8/dep-bin-adder-309a7669209f2ef8"}}],"rustflags":[],"metadata":15972075885573944569} \ No newline at end of file diff --git a/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/dep-bin-adder-309a7669209f2ef8 b/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/dep-bin-adder-309a7669209f2ef8 new file mode 100644 index 00000000..cdefce33 Binary files /dev/null and b/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/dep-bin-adder-309a7669209f2ef8 differ diff --git a/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/invoked.timestamp b/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/invoked.timestamp new file mode 100644 index 00000000..e00328da --- /dev/null +++ b/addr/target/debug/.fingerprint/adder-309a7669209f2ef8/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/bin-adder-dbdfdc450c2d3728 b/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/bin-adder-dbdfdc450c2d3728 new file mode 100644 index 00000000..bfefa14a --- /dev/null +++ b/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/bin-adder-dbdfdc450c2d3728 @@ -0,0 +1 @@ +650e2d912115d760 \ No newline at end of file diff --git a/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/bin-adder-dbdfdc450c2d3728.json b/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/bin-adder-dbdfdc450c2d3728.json new file mode 100644 index 00000000..b566298f --- /dev/null +++ b/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/bin-adder-dbdfdc450c2d3728.json @@ -0,0 +1 @@ +{"rustc":10683586082858123265,"features":"[]","target":9805538687745692616,"profile":14996655781355331481,"path":7714536825948459707,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/adder-dbdfdc450c2d3728/dep-bin-adder-dbdfdc450c2d3728"}}],"rustflags":[],"metadata":15972075885573944569} \ No newline at end of file diff --git a/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/dep-bin-adder-dbdfdc450c2d3728 b/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/dep-bin-adder-dbdfdc450c2d3728 new file mode 100644 index 00000000..cdefce33 Binary files /dev/null and b/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/dep-bin-adder-dbdfdc450c2d3728 differ diff --git a/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/invoked.timestamp b/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/invoked.timestamp new file mode 100644 index 00000000..e00328da --- /dev/null +++ b/addr/target/debug/.fingerprint/adder-dbdfdc450c2d3728/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/addr/target/debug/adder b/addr/target/debug/adder new file mode 100755 index 00000000..684b964a Binary files /dev/null and b/addr/target/debug/adder differ diff --git a/addr/target/debug/adder.d b/addr/target/debug/adder.d new file mode 100644 index 00000000..7172d9f6 --- /dev/null +++ b/addr/target/debug/adder.d @@ -0,0 +1 @@ +/home/andy/source/rust/learn_rust/addr/target/debug/adder: /home/andy/source/rust/learn_rust/addr/add-one/src/lib.rs /home/andy/source/rust/learn_rust/addr/adder/src/main.rs diff --git a/addr/target/debug/deps/add_one-f25b03445ef13e1f.d b/addr/target/debug/deps/add_one-f25b03445ef13e1f.d new file mode 100644 index 00000000..be1fbcd8 --- /dev/null +++ b/addr/target/debug/deps/add_one-f25b03445ef13e1f.d @@ -0,0 +1,7 @@ +/home/andy/source/rust/learn_rust/addr/target/debug/deps/add_one-f25b03445ef13e1f.rmeta: add-one/src/lib.rs + +/home/andy/source/rust/learn_rust/addr/target/debug/deps/libadd_one-f25b03445ef13e1f.rlib: add-one/src/lib.rs + +/home/andy/source/rust/learn_rust/addr/target/debug/deps/add_one-f25b03445ef13e1f.d: add-one/src/lib.rs + +add-one/src/lib.rs: diff --git a/addr/target/debug/deps/adder-309a7669209f2ef8 b/addr/target/debug/deps/adder-309a7669209f2ef8 new file mode 100755 index 00000000..684b964a Binary files /dev/null and b/addr/target/debug/deps/adder-309a7669209f2ef8 differ diff --git a/addr/target/debug/deps/adder-309a7669209f2ef8.d b/addr/target/debug/deps/adder-309a7669209f2ef8.d new file mode 100644 index 00000000..07763096 --- /dev/null +++ b/addr/target/debug/deps/adder-309a7669209f2ef8.d @@ -0,0 +1,5 @@ +/home/andy/source/rust/learn_rust/addr/target/debug/deps/adder-309a7669209f2ef8: adder/src/main.rs + +/home/andy/source/rust/learn_rust/addr/target/debug/deps/adder-309a7669209f2ef8.d: adder/src/main.rs + +adder/src/main.rs: diff --git a/addr/target/debug/deps/adder-dbdfdc450c2d3728 b/addr/target/debug/deps/adder-dbdfdc450c2d3728 new file mode 100755 index 00000000..c5ad5f46 Binary files /dev/null and b/addr/target/debug/deps/adder-dbdfdc450c2d3728 differ diff --git a/addr/target/debug/deps/adder-dbdfdc450c2d3728.d b/addr/target/debug/deps/adder-dbdfdc450c2d3728.d new file mode 100644 index 00000000..7cf546fc --- /dev/null +++ b/addr/target/debug/deps/adder-dbdfdc450c2d3728.d @@ -0,0 +1,5 @@ +/home/andy/source/rust/learn_rust/addr/target/debug/deps/adder-dbdfdc450c2d3728: adder/src/main.rs + +/home/andy/source/rust/learn_rust/addr/target/debug/deps/adder-dbdfdc450c2d3728.d: adder/src/main.rs + +adder/src/main.rs: diff --git a/addr/target/debug/deps/libadd_one-f25b03445ef13e1f.rlib b/addr/target/debug/deps/libadd_one-f25b03445ef13e1f.rlib new file mode 100644 index 00000000..561199ac Binary files /dev/null and b/addr/target/debug/deps/libadd_one-f25b03445ef13e1f.rlib differ diff --git a/addr/target/debug/deps/libadd_one-f25b03445ef13e1f.rmeta b/addr/target/debug/deps/libadd_one-f25b03445ef13e1f.rmeta new file mode 100644 index 00000000..abcf28a2 Binary files /dev/null and b/addr/target/debug/deps/libadd_one-f25b03445ef13e1f.rmeta differ diff --git a/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/2e6vg10282lxf89y.bc.z b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/2e6vg10282lxf89y.bc.z new file mode 100644 index 00000000..94e3cf3b Binary files /dev/null and b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/2e6vg10282lxf89y.bc.z differ diff --git a/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/2e6vg10282lxf89y.o b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/2e6vg10282lxf89y.o new file mode 100644 index 00000000..06c7ee0a Binary files /dev/null and b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/2e6vg10282lxf89y.o differ diff --git a/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/dep-graph.bin b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/dep-graph.bin new file mode 100644 index 00000000..aca4adf4 Binary files /dev/null and b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/dep-graph.bin differ diff --git a/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/query-cache.bin b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/query-cache.bin new file mode 100644 index 00000000..cb32cdbd Binary files /dev/null and b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/query-cache.bin differ diff --git a/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/work-products.bin b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/work-products.bin new file mode 100644 index 00000000..2ad7a9dd Binary files /dev/null and b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8-7de5weahnv2d/work-products.bin differ diff --git a/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8.lock b/addr/target/debug/incremental/add_one-3vs39ya9gg3tk/s-fjtves2187-152gsu8.lock new file mode 100755 index 00000000..e69de29b diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/10s23n0a6gu0rcmo.o b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/10s23n0a6gu0rcmo.o new file mode 100644 index 00000000..39fe21da Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/10s23n0a6gu0rcmo.o differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/29zekqtk48o6qaar.o b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/29zekqtk48o6qaar.o new file mode 100644 index 00000000..847b3485 Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/29zekqtk48o6qaar.o differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/4801hdn43zi2wtk6.o b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/4801hdn43zi2wtk6.o new file mode 100644 index 00000000..ccb1bdc9 Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/4801hdn43zi2wtk6.o differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/49cbk1z7lqm9skq7.o b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/49cbk1z7lqm9skq7.o new file mode 100644 index 00000000..f8de8352 Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/49cbk1z7lqm9skq7.o differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/4andkutzka9pphiw.o b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/4andkutzka9pphiw.o new file mode 100644 index 00000000..78a11060 Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/4andkutzka9pphiw.o differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/5q9gi0jomkvmpgs.o b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/5q9gi0jomkvmpgs.o new file mode 100644 index 00000000..0fc62ab1 Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/5q9gi0jomkvmpgs.o differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/dep-graph.bin b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/dep-graph.bin new file mode 100644 index 00000000..317a851b Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/dep-graph.bin differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/e9hlta7t4i09ut5.o b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/e9hlta7t4i09ut5.o new file mode 100644 index 00000000..a88fe23f Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/e9hlta7t4i09ut5.o differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/query-cache.bin b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/query-cache.bin new file mode 100644 index 00000000..128f1e7a Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/query-cache.bin differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/work-products.bin b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/work-products.bin new file mode 100644 index 00000000..91e91f74 Binary files /dev/null and b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj-1mjmsxs7mb0ru/work-products.bin differ diff --git a/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj.lock b/addr/target/debug/incremental/adder-2zlut5gw97la6/s-fjtves3y72-xe17gj.lock new file mode 100755 index 00000000..e69de29b diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/4963j9ki9h0xb7uz.o b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/4963j9ki9h0xb7uz.o new file mode 100644 index 00000000..48c6585b Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/4963j9ki9h0xb7uz.o differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/4y75dxb1x9s2ixnz.o b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/4y75dxb1x9s2ixnz.o new file mode 100644 index 00000000..399caefc Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/4y75dxb1x9s2ixnz.o differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/52txsirt7a4bao72.o b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/52txsirt7a4bao72.o new file mode 100644 index 00000000..de3c40ab Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/52txsirt7a4bao72.o differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/55qs04ynuluedmr9.o b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/55qs04ynuluedmr9.o new file mode 100644 index 00000000..2f8093db Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/55qs04ynuluedmr9.o differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/5em9nqkr37bv8cah.o b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/5em9nqkr37bv8cah.o new file mode 100644 index 00000000..73f6ce9c Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/5em9nqkr37bv8cah.o differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/dep-graph.bin b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/dep-graph.bin new file mode 100644 index 00000000..0ed31a41 Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/dep-graph.bin differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/oc0vfkdls8gu9fr.o b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/oc0vfkdls8gu9fr.o new file mode 100644 index 00000000..078087f1 Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/oc0vfkdls8gu9fr.o differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/query-cache.bin b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/query-cache.bin new file mode 100644 index 00000000..1f0577c8 Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/query-cache.bin differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/work-products.bin b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/work-products.bin new file mode 100644 index 00000000..99da362e Binary files /dev/null and b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g-1r9aw2w50luog/work-products.bin differ diff --git a/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g.lock b/addr/target/debug/incremental/adder-3blov9qaoykhv/s-fjtv9h7jww-1oliz5g.lock new file mode 100755 index 00000000..e69de29b diff --git a/addr/target/debug/libadd_one.d b/addr/target/debug/libadd_one.d new file mode 100644 index 00000000..623c0559 --- /dev/null +++ b/addr/target/debug/libadd_one.d @@ -0,0 +1 @@ +/home/andy/source/rust/learn_rust/addr/target/debug/libadd_one.rlib: /home/andy/source/rust/learn_rust/addr/add-one/src/lib.rs diff --git a/addr/target/debug/libadd_one.rlib b/addr/target/debug/libadd_one.rlib new file mode 100644 index 00000000..561199ac Binary files /dev/null and b/addr/target/debug/libadd_one.rlib differ diff --git a/hello/.gitignore b/hello/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/hello/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/hello/Cargo.lock b/hello/Cargo.lock new file mode 100644 index 00000000..f2d069f4 --- /dev/null +++ b/hello/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "hello" +version = "0.1.0" + diff --git a/hello/Cargo.toml b/hello/Cargo.toml new file mode 100644 index 00000000..29380df0 --- /dev/null +++ b/hello/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "hello" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/hello/src/main.rs b/hello/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/hello/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/learn_T/.gitignore b/learn_T/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_T/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_T/Cargo.lock b/learn_T/Cargo.lock new file mode 100644 index 00000000..b6228c15 --- /dev/null +++ b/learn_T/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_T" +version = "0.1.0" + diff --git a/learn_T/Cargo.toml b/learn_T/Cargo.toml new file mode 100644 index 00000000..afffc6cb --- /dev/null +++ b/learn_T/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_T" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_T/src/main.rs b/learn_T/src/main.rs new file mode 100644 index 00000000..ddf91470 --- /dev/null +++ b/learn_T/src/main.rs @@ -0,0 +1,137 @@ +//1、泛型是具体类型或者其它属性的抽象替代,用于减少代码重复. +//2、在函数定义中使用泛型。 +//3、在结构体中使用泛型。 +//4、枚举中的泛型。 +//5、方法中的泛型。 +//6、总结:使用泛型并不会造成程序性能上的损失。rust通过在编译时进行泛型代码的单态化来保证效率。单态化时通过填充编译时使用的具体类型,将通用代码转换为特定代码的过程。 +////--------没有泛型----------- +////for i32 +//fn largest_i32(list: &[i32]) -> i32 { +// let mut largest = list[0]; +// for &item in list.iter() { +// if item > largest { +// largest = item; +// } +// } +// +// largest +//} +// +////for char +//fn largest_char(list: &[char]) -> char { +// let mut largest = list[0]; +// for &item in list.iter() { +// if item > largest { +// largest = item; +// } +// } +// +// largest +//} + +////----------使用泛型------------- +//fn largest (list: &[T]) -> T { +// let mut larger = list[0]; +// for &item in list.iter() { +// if item > larger { +// larger = item; +// } +// } +// larger +//} +// +//fn main() { +// let number_list = vec![1, 2, 23, 34, 8, 100]; +// //let max_number = largest_i32(&number_list); +// let max_number = largest(&number_list); +// println!("max_number = {}", max_number); +// +// let char_list= vec!['a', 'y', 'b']; +// //let max_char = largest_char(&char_list); +// let max_char = largest(&char_list); +// println!("max_char = {}", max_char); +// println!("Hello, world!"); +//} + + +////------在结构体中使用泛型-------- +//#[derive(Debug)] +//struct Point { +// x: T, +// y: T, +//} +// +//#[derive(Debug)] +//struct Point2 { +// x: T, +// y: U, +//} +// +//fn main() { +// let integer = Point{x: 1, y: 2}; +// println!("{:#?}", integer); +// +// let float = Point{x: 1.1, y: 2.2}; +// println!("{:?}", float); +// +// let a = Point2{x: 1.1, y: 'a'}; +// println!("a = {:?}", a); +//} +// +////----------在枚举中使用泛型------------ +//enum Option { +// Some(T), +// None, +//} +// +//enum Result { +// Ok(T), +// Err(E) +//} +////---------------------------------------- + +//-----------在方法中使用泛型-------------- +struct Point { + x: T, + y: T, +} + +impl Point { + fn get_x(&self) -> &T { + &self.x + } + + fn get_y(&self) -> &T { + &self.y + } +} + +struct Point2 { + x: T, + y: U, +} + +impl Point2 { + fn creat_point(self, other: Point2) -> Point2 { + Point2 { + x: self.x, + y: other.y, + } + } +} + + +fn main() { + let p = Point{x:1, y: 2}; + println!("x = {}", p.get_x()); + println!("y = {}", p.get_y()); + + let p = Point{x:1.1, y: 2.2}; + println!("x = {}", p.get_x()); + println!("y = {}", p.get_y()); + + let p1 = Point2{x: 5, y: 1.1}; + let p2 = Point2{x: "hello", y: 'c'}; + let p3 = p1.creat_point(p2); + println!("p3.x = {}, p3.y = {}", p3.x, p3.y); +} diff --git a/learn_box/.gitignore b/learn_box/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_box/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_box/Cargo.lock b/learn_box/Cargo.lock new file mode 100644 index 00000000..85afd9d1 --- /dev/null +++ b/learn_box/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_box" +version = "0.1.0" + diff --git a/learn_box/Cargo.toml b/learn_box/Cargo.toml new file mode 100644 index 00000000..bd4dcb20 --- /dev/null +++ b/learn_box/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_box" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_box/src/main.rs b/learn_box/src/main.rs new file mode 100644 index 00000000..b96ba8d2 --- /dev/null +++ b/learn_box/src/main.rs @@ -0,0 +1,11 @@ +//1、最简单最直接的智能指针是box,其类型为Box。box允许将值放在堆上而不是栈上,留着栈上的则是指向堆数据的指针。除了数据被存储在堆上外,box没有任何性能损失。 +// +//2、box适合用于如下场景: +//(1)当有一个在编译时未知大小的类型,而又需要再确切大小的上下文中使用这个类型值的时候;(举例子:在一个list环境下,存放数据,但是每个元素的大小在编译时又不确定) +//(2)当有大量数据并希望在确保数据不被拷贝的情况下转移所有权的时候; +//(3)当希望拥有一个值并只关心它的类型是否实现了特定trait而不是其具体类型时。 +fn main() { + let b = Box::new(5); //b存储于栈上,5存储在堆上,b指向5所在的内存 + println!("b = {}", b); + println!("Hello, world!"); +} diff --git a/learn_box1/.gitignore b/learn_box1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_box1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_box1/Cargo.lock b/learn_box1/Cargo.lock new file mode 100644 index 00000000..251c5bef --- /dev/null +++ b/learn_box1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_box1" +version = "0.1.0" + diff --git a/learn_box1/Cargo.toml b/learn_box1/Cargo.toml new file mode 100644 index 00000000..c5be20f5 --- /dev/null +++ b/learn_box1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_box1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_box1/src/main.rs b/learn_box1/src/main.rs new file mode 100644 index 00000000..8800407f --- /dev/null +++ b/learn_box1/src/main.rs @@ -0,0 +1,32 @@ +//box适合用于如下场景: +//(1)当有一个在编译时未知大小的类型,而又需要再确切大小的上下文中使用这个类型值的时候;(举例子:在一个list环境下,存放数据,但是每个元素的大小在编译时又不确定) +//(2)当有大量数据并希望在确保数据不被拷贝的情况下转移所有权的时候; +//(3)当希望拥有一个值并只关心它的类型是否实现了特定trait而不是其具体类型时。 +//enum List { +// Cons(i32, List), +// Nil, +//} + +enum List { + Cons(i32, Box), + Nil, +} + +//struct List { +// int value; +// struct List *next; +// //struct List l; +//}; + +// +fn main() { + use List::Cons; + use List::Nil; + //let list = Cons(1, Cons(2, Cons(3, Nil))); + + let list = Cons(1, + Box::new(Cons(2, + Box::new(Cons(3, + Box::new(Nil)))))); + println!("Hello, world!"); +} diff --git a/learn_cargo1/.gitignore b/learn_cargo1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_cargo1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_cargo1/Cargo.lock b/learn_cargo1/Cargo.lock new file mode 100644 index 00000000..051cee66 --- /dev/null +++ b/learn_cargo1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_cargo1" +version = "0.1.0" + diff --git a/learn_cargo1/Cargo.toml b/learn_cargo1/Cargo.toml new file mode 100644 index 00000000..faf0d6eb --- /dev/null +++ b/learn_cargo1/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "learn_cargo1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[profile.dev] +opt-level = 0 + +[profile.release] +opt-level = 1 diff --git a/learn_cargo1/src/main.rs b/learn_cargo1/src/main.rs new file mode 100644 index 00000000..fd69ca0c --- /dev/null +++ b/learn_cargo1/src/main.rs @@ -0,0 +1,21 @@ +fn main() { + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); + println!("Hello, world!"); +} diff --git a/learn_closure1/.gitignore b/learn_closure1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_closure1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_closure1/Cargo.lock b/learn_closure1/Cargo.lock new file mode 100644 index 00000000..ebabb9a9 --- /dev/null +++ b/learn_closure1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_closure1" +version = "0.1.0" + diff --git a/learn_closure1/Cargo.toml b/learn_closure1/Cargo.toml new file mode 100644 index 00000000..9b86866f --- /dev/null +++ b/learn_closure1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_closure1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_closure1/src/main.rs b/learn_closure1/src/main.rs new file mode 100644 index 00000000..8dd9958c --- /dev/null +++ b/learn_closure1/src/main.rs @@ -0,0 +1,42 @@ +//1、闭包是可以保存进变量或者作为参数传递给其它函数的匿名函数。闭包和函数不同的是,闭包允许捕获调用者作用域中的值。 +//2、闭包的使用方式 +//3、使用带有泛型和Fn trait的闭包 +fn main() { + let use_closure = || { + println!("This is a closure"); + }; + use_closure(); + println!("Hello, world!"); + + //闭包定义会为每个参数和返回值类型推导一个具体的类型,但是不能推导两次 + let add_one_v2 = |x: u32| -> u32 { x + 1 }; + let add_one_v3 = |x| {x + 1}; + let add_one_v4 = |x| x+1; + + let a = add_one_v1(5);//use function + let b = add_one_v2(5); + let c = add_one_v3(5); + let d = add_one_v4(5); + println!("a = {}, b = {}, c = {}, d = {}", a, b, c, d); + + //不能推导两次的例子 + let example_closure = |x| x; + let s = example_closure(String::from("hello")); + println!("s = {}", s); + + //let n = example_closure(5); + let n = example_closure(5.to_string()); + println!("n = {}", n); + + //捕捉环境中的变量 + let i = 1; + let exe = |x| {x+i}; + let r = exe(5); + println!("r = {}", r); +} + +//语法格式 +fn add_one_v1(x: u32) -> u32 { + x + 1 +} + diff --git a/learn_closure2/.gitignore b/learn_closure2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_closure2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_closure2/Cargo.lock b/learn_closure2/Cargo.lock new file mode 100644 index 00000000..345bd44e --- /dev/null +++ b/learn_closure2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_closure2" +version = "0.1.0" + diff --git a/learn_closure2/Cargo.toml b/learn_closure2/Cargo.toml new file mode 100644 index 00000000..aa41fc90 --- /dev/null +++ b/learn_closure2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_closure2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_closure2/src/main.rs b/learn_closure2/src/main.rs new file mode 100644 index 00000000..ef303470 --- /dev/null +++ b/learn_closure2/src/main.rs @@ -0,0 +1,39 @@ +//实现一个缓存,只处理第一次传入的值并保存 +struct Cacher + where T: Fn(u32) -> u32 +{ + calcuation: T, + value: Option, +} + +impl Cacher + where T: Fn(u32) -> u32 +{ + fn new(calcuation: T) -> Cacher { + Cacher { + calcuation, + value: None, + } + } + + fn value(&mut self, arg: u32) -> u32 { + match self.value { + Some(v) => v, + None => { + let v = (self.calcuation)(arg); + self.value = Some(v); + v + }, + } + } +} + +fn main() { + let mut c = Cacher::new(|x| x+1); + let v1 = c.value(1); + println!("v1 = {}", v1); + + let v2 = c.value(2); + println!("v2 = {}", v2); + println!("Hello, world!"); +} diff --git a/learn_closure3/.gitignore b/learn_closure3/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_closure3/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_closure3/Cargo.lock b/learn_closure3/Cargo.lock new file mode 100644 index 00000000..2ba8f0f4 --- /dev/null +++ b/learn_closure3/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_closure3" +version = "0.1.0" + diff --git a/learn_closure3/Cargo.toml b/learn_closure3/Cargo.toml new file mode 100644 index 00000000..425815e2 --- /dev/null +++ b/learn_closure3/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_closure3" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_closure3/src/main.rs b/learn_closure3/src/main.rs new file mode 100644 index 00000000..6aad34f0 --- /dev/null +++ b/learn_closure3/src/main.rs @@ -0,0 +1,20 @@ +fn main() { + //let x = 4; + //let equal_to_x = |z| z==x; + //let y = 4; + //assert!(equal_to_x(y)); + + let x = vec![1, 2, 3]; + let equal_to_x = move |z| {z==x}; + println!("x === {:?}", x); + + let y = vec![1, 2, 3]; + assert!(equal_to_x(y)); +} + +//闭包可以通过三种方式捕获其环境,它们对应函数的三种获取参数的方式,分别是获取所有权、可变借用、不可变借用。 +//这三种捕获值的方式被编码为如下三个Fn trait: +//(1)FnOnce消费从周围作用域捕获的变量,闭包周围的作用域被称为其环境。为了消费捕获到的变量,闭包必须获取其所有权并在定义闭包时将其移进闭包。其名称的Once部分代表了闭包不能多次获取相同变量的所有权。 +//(2)FnMut获取可变的借用值,所以可以改变其环境。 +//(3)Fn从其环境获取不可变的借用值。 +//当创建一个闭包时,rust会根据其如何使用环境中的变量来推断我们希望如何引用环境。由于所有闭包都可以被调用至少一次,因此所有闭包都实现了FnOnce。没有移动被捕获变量的所有权到闭包的闭包也实现了FnMut,而不需要对捕获的变量进行可变访问的闭包实现了Fn。 diff --git a/learn_con/.gitignore b/learn_con/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_con/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_con/Cargo.lock b/learn_con/Cargo.lock new file mode 100644 index 00000000..d5d67a5c --- /dev/null +++ b/learn_con/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_con" +version = "0.1.0" + diff --git a/learn_con/Cargo.toml b/learn_con/Cargo.toml new file mode 100644 index 00000000..c1969c8f --- /dev/null +++ b/learn_con/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_con" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_con/src/main.rs b/learn_con/src/main.rs new file mode 100644 index 00000000..2b9d03fa --- /dev/null +++ b/learn_con/src/main.rs @@ -0,0 +1,74 @@ +fn main() { + //if + let y = 0; + if y == 1 { + println!("y = 1"); + } + + //if-else + if y == 1 { + println!("y = 1"); + } else { + println!("y != 1"); + } + + //if - else if - else + println!("++++++++++++"); + let y = 2; + if y == 1 { + println!("y = 1"); + } else if y == 0 { + println!("y = 0"); + } else if y == 2 { + println!("y = 2"); + } else { + println!("other"); + } + + //let中使用if + let condition = true; + let x = if condition { + 5 + } else { + 6 + //"six" //error + }; + + println!("x = {}", x); + + //loop + let mut counter = 0; + loop { + println!("in loop"); + if counter == 10 { + break; + } + + //counter = counter + 1; + counter += 1; + } + + let result = loop { + counter += 1; + if counter == 20 { + break counter*2; + } + }; + println!("result = {}", result); + + //while + let mut i = 0; + while i != 10 { + i += 1; + } + println!("i = {}", i); + + //for + println!("+++++++++++++++"); + let arr:[u32; 5] = [1, 2, 3, 4, 5]; + //for element in arr.iter() { + for element in &arr { + println!("element = {}", element); + } + println!("Hello, world!"); +} diff --git a/learn_crate/.gitignore b/learn_crate/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_crate/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_crate/Cargo.lock b/learn_crate/Cargo.lock new file mode 100644 index 00000000..85374119 --- /dev/null +++ b/learn_crate/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_crate" +version = "0.1.0" + diff --git a/learn_crate/Cargo.toml b/learn_crate/Cargo.toml new file mode 100644 index 00000000..ad32877e --- /dev/null +++ b/learn_crate/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_crate" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_crate/src/main.rs b/learn_crate/src/main.rs new file mode 100644 index 00000000..a596777e --- /dev/null +++ b/learn_crate/src/main.rs @@ -0,0 +1,19 @@ +mod factory { + pub mod produce_refrigerator { + pub fn produce_re() { + println!("produce refrigerator!"); + } + } + + mod produce_washing_machine { + fn produce_washing() { + println!("produce washing machine!"); + } + } +} + +fn main() { + factory::produce_refrigerator::produce_re(); + + println!("Hello, world!"); +} diff --git a/learn_crate1/.gitignore b/learn_crate1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_crate1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_crate1/Cargo.lock b/learn_crate1/Cargo.lock new file mode 100644 index 00000000..a02f4814 --- /dev/null +++ b/learn_crate1/Cargo.lock @@ -0,0 +1,133 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "learn_crate1" +version = "0.1.0" +dependencies = [ + "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.2.66" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rust-crypto" +version = "0.2.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-serialize" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" +"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" +"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" +"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" +"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/learn_crate1/Cargo.toml b/learn_crate1/Cargo.toml new file mode 100644 index 00000000..389a4d8a --- /dev/null +++ b/learn_crate1/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "learn_crate1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rust-crypto = "0.2" diff --git a/learn_crate1/mylib/Cargo.lock b/learn_crate1/mylib/Cargo.lock new file mode 100644 index 00000000..fb971d6f --- /dev/null +++ b/learn_crate1/mylib/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "mylib" +version = "0.1.0" + diff --git a/learn_crate1/mylib/Cargo.toml b/learn_crate1/mylib/Cargo.toml new file mode 100644 index 00000000..2e9d8c26 --- /dev/null +++ b/learn_crate1/mylib/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "mylib" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_crate1/mylib/src/lib.rs b/learn_crate1/mylib/src/lib.rs new file mode 100644 index 00000000..13bf5cc7 --- /dev/null +++ b/learn_crate1/mylib/src/lib.rs @@ -0,0 +1,34 @@ +//! My Crate +//! +//! 'my_crate' is a collection of utilites to make performing certain calcuations more convenient +//! +/// Add one to the number given +/// +/// #Example +/// +/// ``` +/// let five = 5; +/// +/// assert_eq!(6, mylib::add_one(5)); +/// ``` +pub fn add_one(x: i32) -> i32 { + x + 1 +} + + + + + + + + + + + +//#[cfg(test)] +//mod tests { +// #[test] +// fn it_works() { +// assert_eq!(2 + 2, 4); +// } +//} diff --git a/learn_crate1/mylib/target/.rustc_info.json b/learn_crate1/mylib/target/.rustc_info.json new file mode 100644 index 00000000..9cdf4038 --- /dev/null +++ b/learn_crate1/mylib/target/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":17989264669760749350,"outputs":{"2196823701345282402":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/andy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\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_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"1164083562126845933":["rustc 1.38.0 (625451e37 2019-09-23)\nbinary: rustc\ncommit-hash: 625451e376bb2e5283fc4741caa0a3e8a2ca4d54\ncommit-date: 2019-09-23\nhost: x86_64-unknown-linux-gnu\nrelease: 1.38.0\nLLVM version: 9.0\n",""],"4476964694761187371":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/andy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\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_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"1138116330425514636":["___\n",""]},"successes":{}} \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/.cargo-lock b/learn_crate1/mylib/target/debug/.cargo-lock new file mode 100644 index 00000000..e69de29b diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-03152f58286628a6/doc-lib-mylib-03152f58286628a6 b/learn_crate1/mylib/target/debug/.fingerprint/mylib-03152f58286628a6/doc-lib-mylib-03152f58286628a6 new file mode 100644 index 00000000..78378836 --- /dev/null +++ b/learn_crate1/mylib/target/debug/.fingerprint/mylib-03152f58286628a6/doc-lib-mylib-03152f58286628a6 @@ -0,0 +1 @@ +ad1227adbb52ea01 \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-03152f58286628a6/doc-lib-mylib-03152f58286628a6.json b/learn_crate1/mylib/target/debug/.fingerprint/mylib-03152f58286628a6/doc-lib-mylib-03152f58286628a6.json new file mode 100644 index 00000000..065fc036 --- /dev/null +++ b/learn_crate1/mylib/target/debug/.fingerprint/mylib-03152f58286628a6/doc-lib-mylib-03152f58286628a6.json @@ -0,0 +1 @@ +{"rustc":10683586082858123265,"features":"[]","target":9023204661465037696,"profile":17366959072056642772,"path":10872709659218687626,"deps":[],"local":[{"Precalculated":"1579339852.698800153s (/home/andy/source/rust/learn_rust/learn_crate1/mylib/src/lib.rs)"}],"rustflags":[],"metadata":15972075885573944569} \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/dep-lib-mylib-76a11366c8786358 b/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/dep-lib-mylib-76a11366c8786358 new file mode 100644 index 00000000..2df294f8 Binary files /dev/null and b/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/dep-lib-mylib-76a11366c8786358 differ diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/invoked.timestamp b/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/invoked.timestamp new file mode 100644 index 00000000..e00328da --- /dev/null +++ b/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358 b/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358 new file mode 100644 index 00000000..85c87add --- /dev/null +++ b/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358 @@ -0,0 +1 @@ +b9bb53fc26387bf4 \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358.json b/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358.json new file mode 100644 index 00000000..cfe0fe8e --- /dev/null +++ b/learn_crate1/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358.json @@ -0,0 +1 @@ +{"rustc":10683586082858123265,"features":"[]","target":9023204661465037696,"profile":14996655781355331481,"path":10872709659218687626,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/mylib-76a11366c8786358/dep-lib-mylib-76a11366c8786358"}}],"rustflags":[],"metadata":15972075885573944569} \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/dep-test-lib-mylib-8daa0161999f343d b/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/dep-test-lib-mylib-8daa0161999f343d new file mode 100644 index 00000000..2df294f8 Binary files /dev/null and b/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/dep-test-lib-mylib-8daa0161999f343d differ diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/invoked.timestamp b/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/invoked.timestamp new file mode 100644 index 00000000..e00328da --- /dev/null +++ b/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d b/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d new file mode 100644 index 00000000..77451b46 --- /dev/null +++ b/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d @@ -0,0 +1 @@ +9e6f6e09989d6992 \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d.json b/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d.json new file mode 100644 index 00000000..27a99dba --- /dev/null +++ b/learn_crate1/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d.json @@ -0,0 +1 @@ +{"rustc":10683586082858123265,"features":"[]","target":9023204661465037696,"profile":8248545651247322450,"path":10872709659218687626,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/mylib-8daa0161999f343d/dep-test-lib-mylib-8daa0161999f343d"}}],"rustflags":[],"metadata":15972075885573944569} \ No newline at end of file diff --git a/learn_crate1/mylib/target/debug/deps/libmylib-76a11366c8786358.rlib b/learn_crate1/mylib/target/debug/deps/libmylib-76a11366c8786358.rlib new file mode 100644 index 00000000..3a8cb71f Binary files /dev/null and b/learn_crate1/mylib/target/debug/deps/libmylib-76a11366c8786358.rlib differ diff --git a/learn_crate1/mylib/target/debug/deps/libmylib-76a11366c8786358.rmeta b/learn_crate1/mylib/target/debug/deps/libmylib-76a11366c8786358.rmeta new file mode 100644 index 00000000..bd5a9f59 Binary files /dev/null and b/learn_crate1/mylib/target/debug/deps/libmylib-76a11366c8786358.rmeta differ diff --git a/learn_crate1/mylib/target/debug/deps/mylib-76a11366c8786358.d b/learn_crate1/mylib/target/debug/deps/mylib-76a11366c8786358.d new file mode 100644 index 00000000..c0b62aea --- /dev/null +++ b/learn_crate1/mylib/target/debug/deps/mylib-76a11366c8786358.d @@ -0,0 +1,7 @@ +/home/andy/source/rust/learn_rust/learn_crate1/mylib/target/debug/deps/mylib-76a11366c8786358.rmeta: src/lib.rs + +/home/andy/source/rust/learn_rust/learn_crate1/mylib/target/debug/deps/libmylib-76a11366c8786358.rlib: src/lib.rs + +/home/andy/source/rust/learn_rust/learn_crate1/mylib/target/debug/deps/mylib-76a11366c8786358.d: src/lib.rs + +src/lib.rs: diff --git a/learn_crate1/mylib/target/debug/deps/mylib-8daa0161999f343d b/learn_crate1/mylib/target/debug/deps/mylib-8daa0161999f343d new file mode 100755 index 00000000..0bc5cb48 Binary files /dev/null and b/learn_crate1/mylib/target/debug/deps/mylib-8daa0161999f343d differ diff --git a/learn_crate1/mylib/target/debug/deps/mylib-8daa0161999f343d.d b/learn_crate1/mylib/target/debug/deps/mylib-8daa0161999f343d.d new file mode 100644 index 00000000..d7885174 --- /dev/null +++ b/learn_crate1/mylib/target/debug/deps/mylib-8daa0161999f343d.d @@ -0,0 +1,5 @@ +/home/andy/source/rust/learn_rust/learn_crate1/mylib/target/debug/deps/mylib-8daa0161999f343d: src/lib.rs + +/home/andy/source/rust/learn_rust/learn_crate1/mylib/target/debug/deps/mylib-8daa0161999f343d.d: src/lib.rs + +src/lib.rs: diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/2nqb23v3oeto94ck.bc.z b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/2nqb23v3oeto94ck.bc.z new file mode 100644 index 00000000..1d75c5d9 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/2nqb23v3oeto94ck.bc.z differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/2nqb23v3oeto94ck.o b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/2nqb23v3oeto94ck.o new file mode 100644 index 00000000..f482c821 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/2nqb23v3oeto94ck.o differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/dep-graph.bin b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/dep-graph.bin new file mode 100644 index 00000000..e53dad95 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/dep-graph.bin differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/query-cache.bin b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/query-cache.bin new file mode 100644 index 00000000..6e8c9e22 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/query-cache.bin differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/work-products.bin b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/work-products.bin new file mode 100644 index 00000000..7b4e2d05 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4-gafy6pbyoh1d/work-products.bin differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4.lock b/learn_crate1/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fjtunbo2av-1quu7y4.lock new file mode 100755 index 00000000..e69de29b diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/36an4yzzbds4xc28.o b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/36an4yzzbds4xc28.o new file mode 100644 index 00000000..0f6567dd Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/36an4yzzbds4xc28.o differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/3jy6a5kzfyqwn34x.o b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/3jy6a5kzfyqwn34x.o new file mode 100644 index 00000000..5cd72399 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/3jy6a5kzfyqwn34x.o differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/3pnyywknnlk3lqpa.o b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/3pnyywknnlk3lqpa.o new file mode 100644 index 00000000..dcefa511 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/3pnyywknnlk3lqpa.o differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/4bym1ojtwdl54cuk.o b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/4bym1ojtwdl54cuk.o new file mode 100644 index 00000000..cc7a1110 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/4bym1ojtwdl54cuk.o differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/dep-graph.bin b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/dep-graph.bin new file mode 100644 index 00000000..f78179ad Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/dep-graph.bin differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/query-cache.bin b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/query-cache.bin new file mode 100644 index 00000000..019d2e00 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/query-cache.bin differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/wkhmx50wcbitygx.o b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/wkhmx50wcbitygx.o new file mode 100644 index 00000000..56c38de7 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/wkhmx50wcbitygx.o differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/work-products.bin b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/work-products.bin new file mode 100644 index 00000000..f5a994a7 Binary files /dev/null and b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz-1g3tow5z4a2jk/work-products.bin differ diff --git a/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz.lock b/learn_crate1/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fjtuncfqip-1ngx1rz.lock new file mode 100755 index 00000000..e69de29b diff --git a/learn_crate1/mylib/target/debug/mylib-8daa0161999f343d b/learn_crate1/mylib/target/debug/mylib-8daa0161999f343d new file mode 100755 index 00000000..0bc5cb48 Binary files /dev/null and b/learn_crate1/mylib/target/debug/mylib-8daa0161999f343d differ diff --git a/learn_crate1/mylib/target/debug/mylib-8daa0161999f343d.d b/learn_crate1/mylib/target/debug/mylib-8daa0161999f343d.d new file mode 100644 index 00000000..2cbbcdd9 --- /dev/null +++ b/learn_crate1/mylib/target/debug/mylib-8daa0161999f343d.d @@ -0,0 +1 @@ +/home/andy/source/rust/learn_rust/learn_crate1/mylib/target/debug/mylib-8daa0161999f343d: /home/andy/source/rust/learn_rust/learn_crate1/mylib/src/lib.rs diff --git a/learn_crate1/mylib/target/doc/.lock b/learn_crate1/mylib/target/doc/.lock new file mode 100755 index 00000000..e69de29b diff --git a/learn_crate1/mylib/target/doc/COPYRIGHT.txt b/learn_crate1/mylib/target/doc/COPYRIGHT.txt new file mode 100644 index 00000000..af77776c --- /dev/null +++ b/learn_crate1/mylib/target/doc/COPYRIGHT.txt @@ -0,0 +1,45 @@ +These documentation pages include resources by third parties. This copyright +file applies only to those resources. The following third party resources are +included, and carry their own copyright notices and license terms: + +* Fira Sans (FiraSans-Regular.woff, FiraSans-Medium.woff): + + Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ + with Reserved Font Name Fira Sans. + + Copyright (c) 2014, Telefonica S.A. + + Licensed under the SIL Open Font License, Version 1.1. + See FiraSans-LICENSE.txt. + +* rustdoc.css, main.js, and playpen.js: + + Copyright 2015 The Rust Developers. + Licensed under the Apache License, Version 2.0 (see LICENSE-APACHE.txt) or + the MIT license (LICENSE-MIT.txt) at your option. + +* normalize.css: + + Copyright (c) Nicolas Gallagher and Jonathan Neal. + Licensed under the MIT license (see LICENSE-MIT.txt). + +* Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff): + + Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), + with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark + of Adobe Systems Incorporated in the United States and/or other countries. + + Licensed under the SIL Open Font License, Version 1.1. + See SourceCodePro-LICENSE.txt. + +* Source Serif Pro (SourceSerifPro-Regular.ttf.woff, + SourceSerifPro-Bold.ttf.woff, SourceSerifPro-It.ttf.woff): + + Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/), with + Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of + Adobe Systems Incorporated in the United States and/or other countries. + + Licensed under the SIL Open Font License, Version 1.1. + See SourceSerifPro-LICENSE.txt. + +This copyright file is intended to be distributed with rustdoc output. diff --git a/learn_crate1/mylib/target/doc/FiraSans-LICENSE.txt b/learn_crate1/mylib/target/doc/FiraSans-LICENSE.txt new file mode 100644 index 00000000..d444ea92 --- /dev/null +++ b/learn_crate1/mylib/target/doc/FiraSans-LICENSE.txt @@ -0,0 +1,94 @@ +Digitized data copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. +with Reserved Font Name < Fira >, + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/learn_crate1/mylib/target/doc/FiraSans-Medium.woff b/learn_crate1/mylib/target/doc/FiraSans-Medium.woff new file mode 100644 index 00000000..7d742c5f Binary files /dev/null and b/learn_crate1/mylib/target/doc/FiraSans-Medium.woff differ diff --git a/learn_crate1/mylib/target/doc/FiraSans-Regular.woff b/learn_crate1/mylib/target/doc/FiraSans-Regular.woff new file mode 100644 index 00000000..d8e0363f Binary files /dev/null and b/learn_crate1/mylib/target/doc/FiraSans-Regular.woff differ diff --git a/learn_crate1/mylib/target/doc/LICENSE-APACHE.txt b/learn_crate1/mylib/target/doc/LICENSE-APACHE.txt new file mode 100644 index 00000000..16fe87b0 --- /dev/null +++ b/learn_crate1/mylib/target/doc/LICENSE-APACHE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/learn_crate1/mylib/target/doc/LICENSE-MIT.txt b/learn_crate1/mylib/target/doc/LICENSE-MIT.txt new file mode 100644 index 00000000..31aa7938 --- /dev/null +++ b/learn_crate1/mylib/target/doc/LICENSE-MIT.txt @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/learn_crate1/mylib/target/doc/SourceCodePro-LICENSE.txt b/learn_crate1/mylib/target/doc/SourceCodePro-LICENSE.txt new file mode 100644 index 00000000..07542572 --- /dev/null +++ b/learn_crate1/mylib/target/doc/SourceCodePro-LICENSE.txt @@ -0,0 +1,93 @@ +Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/learn_crate1/mylib/target/doc/SourceCodePro-Regular.woff b/learn_crate1/mylib/target/doc/SourceCodePro-Regular.woff new file mode 100644 index 00000000..55766709 Binary files /dev/null and b/learn_crate1/mylib/target/doc/SourceCodePro-Regular.woff differ diff --git a/learn_crate1/mylib/target/doc/SourceCodePro-Semibold.woff b/learn_crate1/mylib/target/doc/SourceCodePro-Semibold.woff new file mode 100644 index 00000000..ca972a11 Binary files /dev/null and b/learn_crate1/mylib/target/doc/SourceCodePro-Semibold.woff differ diff --git a/learn_crate1/mylib/target/doc/SourceSerifPro-Bold.ttf.woff b/learn_crate1/mylib/target/doc/SourceSerifPro-Bold.ttf.woff new file mode 100644 index 00000000..ca254318 Binary files /dev/null and b/learn_crate1/mylib/target/doc/SourceSerifPro-Bold.ttf.woff differ diff --git a/learn_crate1/mylib/target/doc/SourceSerifPro-It.ttf.woff b/learn_crate1/mylib/target/doc/SourceSerifPro-It.ttf.woff new file mode 100644 index 00000000..a287bbe6 Binary files /dev/null and b/learn_crate1/mylib/target/doc/SourceSerifPro-It.ttf.woff differ diff --git a/learn_crate1/mylib/target/doc/SourceSerifPro-LICENSE.md b/learn_crate1/mylib/target/doc/SourceSerifPro-LICENSE.md new file mode 100644 index 00000000..22cb755f --- /dev/null +++ b/learn_crate1/mylib/target/doc/SourceSerifPro-LICENSE.md @@ -0,0 +1,93 @@ +Copyright 2014-2018 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/learn_crate1/mylib/target/doc/SourceSerifPro-Regular.ttf.woff b/learn_crate1/mylib/target/doc/SourceSerifPro-Regular.ttf.woff new file mode 100644 index 00000000..a3d55cfd Binary files /dev/null and b/learn_crate1/mylib/target/doc/SourceSerifPro-Regular.ttf.woff differ diff --git a/learn_crate1/mylib/target/doc/aliases.js b/learn_crate1/mylib/target/doc/aliases.js new file mode 100644 index 00000000..475f1440 --- /dev/null +++ b/learn_crate1/mylib/target/doc/aliases.js @@ -0,0 +1,2 @@ +var ALIASES = {}; +ALIASES["mylib"] = {}; diff --git a/learn_crate1/mylib/target/doc/brush.svg b/learn_crate1/mylib/target/doc/brush.svg new file mode 100644 index 00000000..072264a6 --- /dev/null +++ b/learn_crate1/mylib/target/doc/brush.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/dark.css b/learn_crate1/mylib/target/doc/dark.css new file mode 100644 index 00000000..0f090c4b --- /dev/null +++ b/learn_crate1/mylib/target/doc/dark.css @@ -0,0 +1 @@ +body{background-color:#353535;color:#ddd;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){color:#ddd;}h1.fqn{border-bottom-color:#d2d2d2;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){border-bottom-color:#d2d2d2;}.in-band{background-color:#353535;}.invisible{background:rgba(0,0,0,0);}.docblock code,.docblock-short code{background-color:#2A2A2A;}pre{background-color:#2A2A2A;}.sidebar{background-color:#505050;}.sidebar .current{background-color:#333;}.source .sidebar{background-color:#353535;}.sidebar .location{border-color:#fff;background:#575757;color:#DDD;}.sidebar .version{border-bottom-color:#DDD;}.sidebar-title{border-top-color:#777;border-bottom-color:#777;}.block a:hover{background:#444;}.line-numbers span{color:#3B91E2;}.line-numbers .line-highlighted{background-color:#0a042f !important;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom-color:#DDD;}.docblock table,.docblock table td,.docblock table th{border-color:#ddd;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#ddd;}.content .highlighted{color:#eee !important;background-color:#616161;}.content .highlighted a,.content .highlighted span{color:#eee !important;}.content .highlighted.trait{background-color:#013191;}.content .highlighted.traitalias{background-color:#013191;}.content .highlighted.mod,.content .highlighted.externcrate{background-color:#afc6e4;}.content .highlighted.mod{background-color:#803a1b;}.content .highlighted.externcrate{background-color:#396bac;}.content .highlighted.enum{background-color:#5b4e68;}.content .highlighted.struct{background-color:#194e9f;}.content .highlighted.union{background-color:#b7bd49;}.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod{background-color:#4950ed;}.content .highlighted.type{background-color:#38902c;}.content .highlighted.foreigntype{background-color:#b200d6;}.content .highlighted.attr,.content .highlighted.derive,.content .highlighted.macro{background-color:#217d1c;}.content .highlighted.constant,.content .highlighted.static{background-color:#0063cc;}.content .highlighted.primitive{background-color:#00708a;}.content .highlighted.keyword{background-color:#884719;}.content span.enum,.content a.enum,.block a.current.enum{color:#82b089;}.content span.struct,.content a.struct,.block a.current.struct{color:#2dbfb8;}.content span.type,.content a.type,.block a.current.type{color:#ff7f00;}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{color:#dd7de8;}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{color:#09bd00;}.content span.union,.content a.union,.block a.current.union{color:#a6ae37;}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{color:#82a5c9;}.content span.primitive,.content a.primitive,.block a.current.primitive{color:#43aec7;}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{color:#bda000;}.content span.trait,.content a.trait,.block a.current.trait{color:#b78cf2;}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{color:#b397da;}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{color:#2BAB63;}.content span.keyword,.content a.keyword,.block a.current.keyword{color:#de5249;}pre.rust .comment{color:#8d8d8b;}pre.rust .doccomment{color:#8ca375;}nav{border-bottom-color:#4e4e4e;}nav.main .current{border-top-color:#eee;border-bottom-color:#eee;}nav.main .separator{border-color:#eee;}a{color:#ddd;}.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),.docblock-short a:not(.srclink):not(.test-arrow),.stability a{color:#D2991D;}.stab.internal a{color:#304FFE;}a.test-arrow{color:#dedede;}.collapse-toggle{color:#999;}#crate-search{color:#111;background-color:#f0f0f0;border-color:#000;box-shadow:0 0 0 1px #000,0 0 0 2px transparent;}.search-input{color:#111;background-color:#f0f0f0;box-shadow:0 0 0 1px #000,0 0 0 2px transparent;}.search-input:focus{border-color:#008dfd;}#crate-search+.search-input:focus{box-shadow:0 0 8px 4px #078dd8;}.module-item .stab{color:#ddd;}.stab.unstable{background:#FFF5D6;border-color:#FFC600;color:#2f2f2f;}.stab.internal{background:#FFB9B3;border-color:#B71C1C;color:#2f2f2f;}.stab.deprecated{background:#F3DFFF;border-color:#7F0087;color:#2f2f2f;}.stab.portability{background:#C4ECFF;border-color:#7BA5DB;color:#2f2f2f;}.stab.portability>code{color:#ddd;}#help>div{background:#4d4d4d;border-color:#bfbfbf;}#help dt{border-color:#bfbfbf;background:rgba(0,0,0,0);color:black;}.since{color:grey;}tr.result span.primitive::after,tr.result span.keyword::after{color:#ddd;}.line-numbers :target{background-color:transparent;}pre.rust .kw{color:#ab8ac1;}pre.rust .kw-2,pre.rust .prelude-ty{color:#769acb;}pre.rust .number,pre.rust .string{color:#83a300;}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{color:#ee6868;}pre.rust .macro,pre.rust .macro-nonterminal{color:#3E999F;}pre.rust .lifetime{color:#d97f26;}pre.rust .question-mark{color:#ff9011;}.example-wrap>pre.line-number{border-color:#4a4949;}a.test-arrow{background-color:rgba(78,139,202,0.2);}a.test-arrow:hover{background-color:#4e8bca;}.toggle-label{color:#999;}:target>code,:target>.in-band{background-color:#494a3d;}pre.compile_fail{border-left:2px solid rgba(255,0,0,.6);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.6);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.6);}.information>.compile_fail:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.6);}.information>.ignore:hover{color:rgba(255,142,0,1);}.search-failed a{color:#0089ff;}.tooltip .tooltiptext{background-color:black;color:#fff;}.tooltip .tooltiptext::after{border-color:transparent black transparent transparent;}.important-traits .tooltip .tooltiptext{background-color:white;color:black;border-color:black;}#titles>div:not(.selected){background-color:#252525;border-top-color:#252525;}#titles>div:hover,#titles>div.selected{border-top-color:#0089ff;}#titles>div>div.count{color:#888;}.modal{background-color:rgba(0,0,0,0.3);}.modal-content{background-color:#272727;border-color:#999;}.modal-content>.close{background-color:#272727;border-color:#999;}.modal-content>.close:hover{background-color:#ff1f1f;color:white;}.modal-content>.whiter{background-color:#272727;}.modal-content>.close:hover+.whiter{background-color:#ff1f1f;}@media (max-width:700px){.sidebar-menu{background-color:#505050;border-bottom-color:#e0e0e0;border-right-color:#e0e0e0;}.sidebar-elems{background-color:#505050;border-right-color:#000;}#sidebar-filler{background-color:#505050;border-bottom-color:#e0e0e0;}}kbd{color:#000;background-color:#fafbfc;border-color:#d1d5da;border-bottom-color:#c6cbd1;box-shadow-color:#c6cbd1;}#theme-picker,#settings-menu{border-color:#e0e0e0;background:#f0f0f0;}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus{border-color:#ffb900;}#theme-choices{border-color:#e0e0e0;background-color:#353535;}#theme-choices>button:not(:first-child){border-top-color:#e0e0e0;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:#4e4e4e;}@media (max-width:700px){#theme-picker{background:#f0f0f0;}}#all-types{background-color:#505050;}#all-types:hover{background-color:#606060;}.search-results td span.alias{color:#fff;}.search-results td span.grey{color:#ccc;}#sidebar-toggle{background-color:#565656;}#sidebar-toggle:hover{background-color:#676767;}#source-sidebar{background-color:#565656;}#source-sidebar>.title{border-bottom-color:#ccc;}div.files>a:hover,div.name:hover{background-color:#444;}div.files>.selected{background-color:#333;} \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/down-arrow.svg b/learn_crate1/mylib/target/doc/down-arrow.svg new file mode 100644 index 00000000..c0f59f0c --- /dev/null +++ b/learn_crate1/mylib/target/doc/down-arrow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/favicon.ico b/learn_crate1/mylib/target/doc/favicon.ico new file mode 100644 index 00000000..b8ad2376 Binary files /dev/null and b/learn_crate1/mylib/target/doc/favicon.ico differ diff --git a/learn_crate1/mylib/target/doc/light.css b/learn_crate1/mylib/target/doc/light.css new file mode 100644 index 00000000..52bbbce4 --- /dev/null +++ b/learn_crate1/mylib/target/doc/light.css @@ -0,0 +1 @@ + body{background-color:white;color:black;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){color:black;}h1.fqn{border-bottom-color:#D5D5D5;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod){border-bottom-color:#DDDDDD;}.in-band{background-color:white;}.invisible{background:rgba(0,0,0,0);}.docblock code,.docblock-short code{background-color:#F5F5F5;}pre{background-color:#F5F5F5;}.sidebar{background-color:#F1F1F1;}.sidebar .current{background-color:#fff;}.source .sidebar{background-color:#fff;}.sidebar .location{border-color:#000;background-color:#fff;color:#333;}.sidebar .version{border-bottom-color:#DDD;}.sidebar-title{border-top-color:#777;border-bottom-color:#777;}.block a:hover{background:#F5F5F5;}.line-numbers span{color:#c67e2d;}.line-numbers .line-highlighted{background-color:#f6fdb0 !important;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom-color:#ddd;}.docblock table,.docblock table td,.docblock table th{border-color:#ddd;}.content .method .where,.content .fn .where,.content .where.fmt-newline{color:#4E4C4C;}.content .highlighted{color:#000 !important;background-color:#ccc;}.content .highlighted a,.content .highlighted span{color:#000 !important;}.content .highlighted.trait{background-color:#c7b6ff;}.content .highlighted.traitalias{background-color:#c7b6ff;}.content .highlighted.mod,.content .highlighted.externcrate{background-color:#afc6e4;}.content .highlighted.enum{background-color:#b4d1b9;}.content .highlighted.struct{background-color:#e7b1a0;}.content .highlighted.union{background-color:#b7bd49;}.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod{background-color:#c6afb3;}.content .highlighted.type{background-color:#ffc891;}.content .highlighted.foreigntype{background-color:#f5c4ff;}.content .highlighted.attr,.content .highlighted.derive,.content .highlighted.macro{background-color:#8ce488;}.content .highlighted.constant,.content .highlighted.static{background-color:#c3e0ff;}.content .highlighted.primitive{background-color:#9aecff;}.content .highlighted.keyword{background-color:#f99650;}.content span.enum,.content a.enum,.block a.current.enum{color:#508157;}.content span.struct,.content a.struct,.block a.current.struct{color:#ad448e;}.content span.type,.content a.type,.block a.current.type{color:#ba5d00;}.content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype{color:#cd00e2;}.content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive,.block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro{color:#068000;}.content span.union,.content a.union,.block a.current.union{color:#767b27;}.content span.constant,.content a.constant,.block a.current.constant,.content span.static,.content a.static,.block a.current.static{color:#546e8a;}.content span.primitive,.content a.primitive,.block a.current.primitive{color:#2c8093;}.content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod{color:#4d76ae;}.content span.trait,.content a.trait,.block a.current.trait{color:#7c5af3;}.content span.traitalias,.content a.traitalias,.block a.current.traitalias{color:#6841f1;}.content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method,.block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod,.content .fnname{color:#9a6e31;}.content span.keyword,.content a.keyword,.block a.current.keyword{color:#de5249;}pre.rust .comment{color:#8E908C;}pre.rust .doccomment{color:#4D4D4C;}nav{border-bottom-color:#e0e0e0;}nav.main .current{border-top-color:#000;border-bottom-color:#000;}nav.main .separator{border:1px solid #000;}a{color:#000;}.docblock:not(.type-decl) a:not(.srclink):not(.test-arrow),.docblock-short a:not(.srclink):not(.test-arrow),.stability a{color:#3873AD;}.stab.internal a{color:#304FFE;}a.test-arrow{color:#f5f5f5;}.collapse-toggle{color:#999;}#crate-search{color:#555;background-color:white;border-color:#e0e0e0;box-shadow:0 0 0 1px #e0e0e0,0 0 0 2px transparent;}.search-input{color:#555;background-color:white;box-shadow:0 0 0 1px #e0e0e0,0 0 0 2px transparent;}.search-input:focus{border-color:#66afe9;}#crate-search+.search-input:focus{box-shadow:0 0 8px #078dd8;}.module-item .stab{color:#000;}.stab.unstable{background:#FFF5D6;border-color:#FFC600;}.stab.internal{background:#FFB9B3;border-color:#B71C1C;}.stab.deprecated{background:#F3DFFF;border-color:#7F0087;}.stab.portability{background:#C4ECFF;border-color:#7BA5DB;}.stab.portability>code{color:#000;}#help>div{background:#e9e9e9;border-color:#bfbfbf;}.since{color:grey;}tr.result span.primitive::after,tr.result span.keyword::after{color:black;}.line-numbers :target{background-color:transparent;}pre.rust .kw{color:#8959A8;}pre.rust .kw-2,pre.rust .prelude-ty{color:#4271AE;}pre.rust .number,pre.rust .string{color:#718C00;}pre.rust .self,pre.rust .bool-val,pre.rust .prelude-val,pre.rust .attribute,pre.rust .attribute .ident{color:#C82829;}pre.rust .macro,pre.rust .macro-nonterminal{color:#3E999F;}pre.rust .lifetime{color:#B76514;}pre.rust .question-mark{color:#ff9011;}.example-wrap>pre.line-number{border-color:#c7c7c7;}a.test-arrow{background-color:rgba(78,139,202,0.2);}a.test-arrow:hover{background-color:#4e8bca;}.toggle-label{color:#999;}:target>code,:target>.in-band{background:#FDFFD3;}pre.compile_fail{border-left:2px solid rgba(255,0,0,.4);}pre.compile_fail:hover,.information:hover+pre.compile_fail{border-left:2px solid #f00;}pre.ignore{border-left:2px solid rgba(255,142,0,.4);}pre.ignore:hover,.information:hover+pre.ignore{border-left:2px solid #ff9200;}.tooltip.compile_fail{color:rgba(255,0,0,.3);}.information>.compile_fail:hover{color:#f00;}.tooltip.ignore{color:rgba(255,142,0,.3);}.information>.ignore:hover{color:rgba(255,142,0,1);}.search-failed a{color:#0089ff;}.tooltip .tooltiptext{background-color:black;color:#fff;}.tooltip .tooltiptext::after{border-color:transparent black transparent transparent;}.important-traits .tooltip .tooltiptext{background-color:white;color:black;border-color:black;}#titles>div:not(.selected){background-color:#e6e6e6;border-top-color:#e6e6e6;}#titles>div:hover,#titles>div.selected{border-top-color:#0089ff;}#titles>div>div.count{color:#888;}.modal{background-color:rgba(0,0,0,0.3);}.modal-content{background-color:#eee;border-color:#999;}.modal-content>.close{background-color:#eee;border-color:#999;}.modal-content>.close:hover{background-color:#ff1f1f;color:white;}.modal-content>.whiter{background-color:#eee;}.modal-content>.close:hover+.whiter{background-color:#ff1f1f;}@media (max-width:700px){.sidebar-menu{background-color:#F1F1F1;border-bottom-color:#e0e0e0;border-right-color:#e0e0e0;}.sidebar-elems{background-color:#F1F1F1;border-right-color:#000;}#sidebar-filler{background-color:#F1F1F1;border-bottom-color:#e0e0e0;}}kbd{color:#000;background-color:#fafbfc;border-color:#d1d5da;border-bottom-color:#c6cbd1;box-shadow-color:#c6cbd1;}#theme-picker,#settings-menu{border-color:#e0e0e0;background-color:#fff;}#theme-picker:hover,#theme-picker:focus,#settings-menu:hover,#settings-menu:focus{border-color:#717171;}#theme-choices{border-color:#ccc;background-color:#fff;}#theme-choices>button:not(:first-child){border-top-color:#e0e0e0;}#theme-choices>button:hover,#theme-choices>button:focus{background-color:#eee;}@media (max-width:700px){#theme-picker{background:#fff;}}#all-types{background-color:#fff;}#all-types:hover{background-color:#f9f9f9;}.search-results td span.alias{color:#000;}.search-results td span.grey{color:#999;}#sidebar-toggle{background-color:#F1F1F1;}#sidebar-toggle:hover{background-color:#E0E0E0;}#source-sidebar{background-color:#F1F1F1;}#source-sidebar>.title{border-bottom-color:#ccc;}div.files>a:hover,div.name:hover{background-color:#E0E0E0;}div.files>.selected{background-color:#fff;} \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/main.js b/learn_crate1/mylib/target/doc/main.js new file mode 100644 index 00000000..37ffbe20 --- /dev/null +++ b/learn_crate1/mylib/target/doc/main.js @@ -0,0 +1 @@ +if(!String.prototype.startsWith){String.prototype.startsWith=function(searchString,position){position=position||0;return this.indexOf(searchString,position)===position}}if(!String.prototype.endsWith){String.prototype.endsWith=function(suffix,length){var l=length||this.length;return this.indexOf(suffix,l-suffix.length)!==-1}}if(!DOMTokenList.prototype.add){DOMTokenList.prototype.add=function(className){if(className&&!hasClass(this,className)){if(this.className&&this.className.length>0){this.className+=" "+className}else{this.className=className}}}}if(!DOMTokenList.prototype.remove){DOMTokenList.prototype.remove=function(className){if(className&&this.className){this.className=(" "+this.className+" ").replace(" "+className+" "," ").trim()}}}(function(){"use strict";var itemTypes=["mod","externcrate","import","struct","enum","fn","type","static","trait","impl","tymethod","method","structfield","variant","macro","primitive","associatedtype","constant","associatedconstant","union","foreigntype","keyword","existential","attr","derive","traitalias"];var search_input=document.getElementsByClassName("search-input")[0];var currentTab=0;var titleBeforeSearch=document.title;function getPageId(){var id=document.location.href.split("#")[1];if(id){return id.split("?")[0].split("&")[0]}return null}function showSidebar(){var elems=document.getElementsByClassName("sidebar-elems")[0];if(elems){addClass(elems,"show-it")}var sidebar=document.getElementsByClassName("sidebar")[0];if(sidebar){addClass(sidebar,"mobile");var filler=document.getElementById("sidebar-filler");if(!filler){var div=document.createElement("div");div.id="sidebar-filler";sidebar.appendChild(div)}}var themePicker=document.getElementsByClassName("theme-picker");if(themePicker&&themePicker.length>0){themePicker[0].style.display="none"}}function hideSidebar(){var elems=document.getElementsByClassName("sidebar-elems")[0];if(elems){removeClass(elems,"show-it")}var sidebar=document.getElementsByClassName("sidebar")[0];removeClass(sidebar,"mobile");var filler=document.getElementById("sidebar-filler");if(filler){filler.remove()}document.getElementsByTagName("body")[0].style.marginTop="";var themePicker=document.getElementsByClassName("theme-picker");if(themePicker&&themePicker.length>0){themePicker[0].style.display=null}}var TY_PRIMITIVE=itemTypes.indexOf("primitive");var TY_KEYWORD=itemTypes.indexOf("keyword");onEachLazy(document.getElementsByClassName("js-only"),function(e){removeClass(e,"js-only")});function getQueryStringParams(){var params={};window.location.search.substring(1).split("&").map(function(s){var pair=s.split("=");params[decodeURIComponent(pair[0])]=typeof pair[1]==="undefined"?null:decodeURIComponent(pair[1])});return params}function browserSupportsHistoryApi(){return window.history&&typeof window.history.pushState==="function"}var main=document.getElementById("main");function highlightSourceLines(ev){hideSidebar();var elem;var search=document.getElementById("search");var i,from,to,match=window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);if(match){from=parseInt(match[1],10);to=from;if(typeof match[2]!=="undefined"){to=parseInt(match[2],10)}if(to0){collapseDocs(collapses[0],"show")}}}}highlightSourceLines(null);window.onhashchange=highlightSourceLines;function getVirtualKey(ev){if("key"in ev&&typeof ev.key!="undefined"){return ev.key}var c=ev.charCode||ev.keyCode;if(c==27){return"Escape"}return String.fromCharCode(c)}function displayHelp(display,ev,help){if(display===true){if(hasClass(help,"hidden")){ev.preventDefault();removeClass(help,"hidden");addClass(document.body,"blur")}}else if(hasClass(help,"hidden")===false){ev.preventDefault();addClass(help,"hidden");removeClass(document.body,"blur")}}function handleEscape(ev,help){hideModal();var search=document.getElementById("search");if(hasClass(help,"hidden")===false){displayHelp(false,ev,help)}else if(hasClass(search,"hidden")===false){ev.preventDefault();addClass(search,"hidden");removeClass(main,"hidden");document.title=titleBeforeSearch}defocusSearchBar()}function handleShortcut(ev){if(ev.ctrlKey||ev.altKey||ev.metaKey){return}var help=document.getElementById("help");if(document.activeElement.tagName==="INPUT"){switch(getVirtualKey(ev)){case"Escape":handleEscape(ev,help);break}}else{switch(getVirtualKey(ev)){case"Escape":handleEscape(ev,help);break;case"s":case"S":displayHelp(false,ev,help);hideModal();ev.preventDefault();focusSearchBar();break;case"+":case"-":ev.preventDefault();toggleAllDocs();break;case"?":if(ev.shiftKey){hideModal();displayHelp(true,ev,help)}break}}}function findParentElement(elem,tagName){do{if(elem&&elem.tagName===tagName){return elem}elem=elem.parentNode}while(elem);return null}document.onkeypress=handleShortcut;document.onkeydown=handleShortcut;document.onclick=function(ev){if(hasClass(ev.target,"collapse-toggle")){collapseDocs(ev.target,"toggle")}else if(hasClass(ev.target.parentNode,"collapse-toggle")){collapseDocs(ev.target.parentNode,"toggle")}else if(ev.target.tagName==="SPAN"&&hasClass(ev.target.parentNode,"line-numbers")){var prev_id=0;var set_fragment=function(name){if(browserSupportsHistoryApi()){history.replaceState(null,null,"#"+name);window.hashchange()}else{location.replace("#"+name)}};var cur_id=parseInt(ev.target.id,10);if(ev.shiftKey&&prev_id){if(prev_id>cur_id){var tmp=prev_id;prev_id=cur_id;cur_id=tmp}set_fragment(prev_id+"-"+cur_id)}else{prev_id=cur_id;set_fragment(cur_id)}}else if(hasClass(document.getElementById("help"),"hidden")===false){addClass(document.getElementById("help"),"hidden");removeClass(document.body,"blur")}else{var a=findParentElement(ev.target,"A");if(a&&a.hash){expandSection(a.hash.replace(/^#/,""))}}};var x=document.getElementsByClassName("version-selector");if(x.length>0){x[0].onchange=function(){var i,match,url=document.location.href,stripped="",len=rootPath.match(/\.\.\//g).length+1;for(i=0;i-1){var obj=searchIndex[results[i].id];obj.lev=results[i].lev;if(isType!==true||obj.type){var res=buildHrefAndPath(obj);obj.displayPath=pathSplitter(res[0]);obj.fullPath=obj.displayPath+obj.name;obj.fullPath+="|"+obj.ty;obj.href=res[1];out.push(obj);if(out.length>=MAX_RESULTS){break}}}}return out}function sortResults(results,isType){var ar=[];for(var entry in results){if(results.hasOwnProperty(entry)){ar.push(results[entry])}}results=ar;var i;var nresults=results.length;for(i=0;ib?+1:-1)}a=(aaa.index<0);b=(bbb.index<0);if(a!==b){return a-b}a=aaa.index;b=bbb.index;if(a!==b){return a-b}if((aaa.item.ty===TY_PRIMITIVE&&bbb.item.ty!==TY_KEYWORD)||(aaa.item.ty===TY_KEYWORD&&bbb.item.ty!==TY_PRIMITIVE)){return-1}if((bbb.item.ty===TY_PRIMITIVE&&aaa.item.ty!==TY_PRIMITIVE)||(bbb.item.ty===TY_KEYWORD&&aaa.item.ty!==TY_KEYWORD)){return 1}a=(aaa.item.desc==="");b=(bbb.item.desc==="");if(a!==b){return a-b}a=aaa.item.ty;b=bbb.item.ty;if(a!==b){return a-b}a=aaa.item.path;b=bbb.item.path;if(a!==b){return(a>b?+1:-1)}return 0});var length=results.length;for(i=0;i"));return{name:val.substring(0,val.indexOf("<")),generics:values.split(/\s*,\s*/),}}return{name:val,generics:[],}}function checkGenerics(obj,val){var lev_distance=MAX_LEV_DISTANCE+1;if(val.generics.length>0){if(obj.length>GENERICS_DATA&&obj[GENERICS_DATA].length>=val.generics.length){var elems=obj[GENERICS_DATA].slice(0);var total=0;var done=0;var vlength=val.generics.length;for(var y=0;yGENERICS_DATA&&obj[GENERICS_DATA].length>=val.generics.length){var elems=obj[GENERICS_DATA].slice(0);var allFound=true;for(var y=0;allFound===true&&yGENERICS_DATA&&obj[GENERICS_DATA].length!==0){var tmp_lev=checkGenerics(obj,val);if(tmp_lev<=MAX_LEV_DISTANCE){return tmp_lev}}else{return 0}}if(literalSearch===true){if(obj.length>GENERICS_DATA&&obj[GENERICS_DATA].length>0){var length=obj[GENERICS_DATA].length;for(x=0;xGENERICS_DATA&&obj[GENERICS_DATA].length>0){var olength=obj[GENERICS_DATA].length;for(x=0;x0){var length=obj.type[INPUTS_DATA].length;for(var i=0;iOUTPUT_DATA){var ret=obj.type[OUTPUT_DATA];if(!obj.type[OUTPUT_DATA].length){ret=[ret]}for(var x=0;xlength){return MAX_LEV_DISTANCE+1}for(var i=0;ilength){break}var lev_total=0;var aborted=false;for(var x=0;xMAX_LEV_DISTANCE){aborted=true;break}lev_total+=lev}if(aborted===false){ret_lev=Math.min(ret_lev,Math.round(lev_total/clength))}}return ret_lev}function typePassesFilter(filter,type){if(filter<0)return true;if(filter===type)return true;var name=itemTypes[type];switch(itemTypes[filter]){case"constant":return(name=="associatedconstant");case"fn":return(name=="method"||name=="tymethod");case"type":return(name=="primitive"||name=="keyword")}return false}function generateId(ty){if(ty.parent&&ty.parent.name){return itemTypes[ty.ty]+ty.path+ty.parent.name+ty.name}return itemTypes[ty.ty]+ty.path+ty.name}var nSearchWords=searchWords.length;var i;var ty;var fullId;var returned;var in_args;if((val.charAt(0)==="\""||val.charAt(0)==="'")&&val.charAt(val.length-1)===val.charAt(0)){val=extractGenerics(val.substr(1,val.length-2));for(i=0;i")>-1){var trimmer=function(s){return s.trim()};var parts=val.split("->").map(trimmer);var input=parts[0];var inputs=input.split(",").map(trimmer).sort();for(i=0;iOUTPUT_DATA?type[OUTPUT_DATA].name:"";returned=checkReturned(ty,output,true);if(output.name==="*"||returned===true){in_args=false;var is_module=false;if(input==="*"){is_module=true}else{var allFound=true;for(var it=0;allFound===true&&it1?paths.length-1:1);for(j=0;j1){lev=checkPath(contains,paths[paths.length-1],ty);if(lev>MAX_LEV_DISTANCE){continue}else if(lev>0){lev_add=1}}returned=MAX_LEV_DISTANCE+1;in_args=MAX_LEV_DISTANCE+1;var index=-1;lev=MAX_LEV_DISTANCE+1;fullId=generateId(ty);if(searchWords[j].indexOf(split[i])>-1||searchWords[j].indexOf(val)>-1||searchWords[j].replace(/_/g,"").indexOf(val)>-1){if(typePassesFilter(typeFilter,ty.ty)&&results[fullId]===undefined){index=searchWords[j].replace(/_/g,"").indexOf(val)}}if((lev=levenshtein(searchWords[j],val))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){lev=MAX_LEV_DISTANCE+1}else{lev+=1}}if((in_args=findArg(ty,valGenerics))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){in_args=MAX_LEV_DISTANCE+1}}if((returned=checkReturned(ty,valGenerics))<=MAX_LEV_DISTANCE){if(typePassesFilter(typeFilter,ty.ty)===false){returned=MAX_LEV_DISTANCE+1}}lev+=lev_add;if(lev>0&&val.length>3&&searchWords[j].indexOf(val)>-1){if(val.length<6){lev-=1}else{lev=0}}if(in_args<=MAX_LEV_DISTANCE){if(results_in_args[fullId]===undefined){results_in_args[fullId]={id:j,index:index,lev:in_args,}}results_in_args[fullId].lev=Math.min(results_in_args[fullId].lev,in_args)}if(returned<=MAX_LEV_DISTANCE){if(results_returned[fullId]===undefined){results_returned[fullId]={id:j,index:index,lev:returned,}}results_returned[fullId].lev=Math.min(results_returned[fullId].lev,returned)}if(index!==-1||lev<=MAX_LEV_DISTANCE){if(index!==-1&&paths.length<2){lev=0}else if(searchWords[j]===val){lev=-1}if(results[fullId]===undefined){results[fullId]={id:j,index:index,lev:lev,}}results[fullId].lev=Math.min(results[fullId].lev,lev)}}}var ret={"in_args":sortResults(results_in_args,true),"returned":sortResults(results_returned,true),"others":sortResults(results),};if(ALIASES&&ALIASES[window.currentCrate]&&ALIASES[window.currentCrate][query.raw]){var aliases=ALIASES[window.currentCrate][query.raw];for(i=0;iMAX_RESULTS){ret.others.pop()}}}return ret}function validateResult(name,path,keys,parent){for(var i=0;i-1||path.indexOf(keys[i])>-1||(parent!==undefined&&parent.name.toLowerCase().indexOf(keys[i])>-1)||levenshtein(name,keys[i])<=MAX_LEV_DISTANCE)){return false}}return true}function getQuery(raw){var matches,type,query;query=raw;matches=query.match(/^(fn|mod|struct|enum|trait|type|const|macro)\s*:\s*/i);if(matches){type=matches[1].replace(/^const$/,"constant");query=query.substring(matches[0].length)}return{raw:raw,query:query,type:type,id:query+type}}function initSearchNav(){var hoverTimeout;var click_func=function(e){var el=e.target;while(el.tagName!=="TR"){el=el.parentNode}var dst=e.target.getElementsByTagName("a");if(dst.length<1){return}dst=dst[0];if(window.location.pathname===dst.pathname){addClass(document.getElementById("search"),"hidden");removeClass(main,"hidden");document.location.href=dst.href}};var mouseover_func=function(e){var el=e.target;while(el.tagName!=="TR"){el=el.parentNode}clearTimeout(hoverTimeout);hoverTimeout=setTimeout(function(){onEachLazy(document.getElementsByClassName("search-results"),function(e){onEachLazy(e.getElementsByClassName("result"),function(i_e){removeClass(i_e,"highlighted")})});addClass(el,"highlighted")},20)};onEachLazy(document.getElementsByClassName("search-results"),function(e){onEachLazy(e.getElementsByClassName("result"),function(i_e){i_e.onclick=click_func;i_e.onmouseover=mouseover_func})});search_input.onkeydown=function(e){var actives=[[],[],[]];var current=0;onEachLazy(document.getElementById("results").childNodes,function(e){onEachLazy(e.getElementsByClassName("highlighted"),function(e){actives[current].push(e)});current+=1});if(e.which===38){if(!actives[currentTab].length||!actives[currentTab][0].previousElementSibling){return}addClass(actives[currentTab][0].previousElementSibling,"highlighted");removeClass(actives[currentTab][0],"highlighted")}else if(e.which===40){if(!actives[currentTab].length){var results=document.getElementById("results").childNodes;if(results.length>0){var res=results[currentTab].getElementsByClassName("result");if(res.length>0){addClass(res[0],"highlighted")}}}else if(actives[currentTab][0].nextElementSibling){addClass(actives[currentTab][0].nextElementSibling,"highlighted");removeClass(actives[currentTab][0],"highlighted")}}else if(e.which===13){if(actives[currentTab].length){document.location.href=actives[currentTab][0].getElementsByTagName("a")[0].href}}else if(e.which===9){if(e.shiftKey){printTab(currentTab>0?currentTab-1:2)}else{printTab(currentTab>1?0:currentTab+1)}e.preventDefault()}else if(e.which===16){}else if(e.which===27){removeClass(actives[currentTab][0],"highlighted");search_input.value="";defocusSearchBar()}else if(actives[currentTab].length>0){removeClass(actives[currentTab][0],"highlighted")}}}function buildHrefAndPath(item){var displayPath;var href;var type=itemTypes[item.ty];var name=item.name;if(type==="mod"){displayPath=item.path+"::";href=rootPath+item.path.replace(/::/g,"/")+"/"+name+"/index.html"}else if(type==="primitive"||type==="keyword"){displayPath="";href=rootPath+item.path.replace(/::/g,"/")+"/"+type+"."+name+".html"}else if(type==="externcrate"){displayPath="";href=rootPath+name+"/index.html"}else if(item.parent!==undefined){var myparent=item.parent;var anchor="#"+type+"."+name;var parentType=itemTypes[myparent.ty];if(parentType==="primitive"){displayPath=myparent.name+"::"}else{displayPath=item.path+"::"+myparent.name+"::"}href=rootPath+item.path.replace(/::/g,"/")+"/"+parentType+"."+myparent.name+".html"+anchor}else{displayPath=item.path+"::";href=rootPath+item.path.replace(/::/g,"/")+"/"+type+"."+name+".html"}return[displayPath,href]}function escape(content){var h1=document.createElement("h1");h1.textContent=content;return h1.innerHTML}function pathSplitter(path){var tmp=""+path.replace(/::/g,"::");if(tmp.endsWith("")){return tmp.slice(0,tmp.length-6)}return tmp}function addTab(array,query,display){var extraStyle="";if(display===false){extraStyle=" style=\"display: none;\""}var output="";var duplicates={};var length=0;if(array.length>0){output="";array.forEach(function(item){var name,type;name=item.name;type=itemTypes[item.ty];if(item.is_alias!==true){if(duplicates[item.fullPath]){return}duplicates[item.fullPath]=true}length+=1;output+=""});output+="
"+""+(item.is_alias===true?(""+item.alias+"  - see "):"")+item.displayPath+""+name+""+""+""+escape(item.desc)+" 
"}else{output="
No results :(
"+"Try on DuckDuckGo?

"+"Or try looking in one of these:
"}return[output,length]}function makeTabHeader(tabNb,text,nbElems){if(currentTab===tabNb){return"
"+text+"
("+nbElems+")
"}return"
"+text+"
("+nbElems+")
"}function showResults(results){if(results.others.length===1&&getCurrentValue("rustdoc-go-to-only-result")==="true"){var elem=document.createElement("a");elem.href=results.others[0].href;elem.style.display="none";document.body.appendChild(elem);elem.click()}var query=getQuery(search_input.value);currentResults=query.id;var ret_others=addTab(results.others,query);var ret_in_args=addTab(results.in_args,query,false);var ret_returned=addTab(results.returned,query,false);var output="

Results for "+escape(query.query)+(query.type?" (type: "+escape(query.type)+")":"")+"

"+"
"+makeTabHeader(0,"In Names",ret_others[1])+makeTabHeader(1,"In Parameters",ret_in_args[1])+makeTabHeader(2,"In Return Types",ret_returned[1])+"
"+ret_others[0]+ret_in_args[0]+ret_returned[0]+"
";addClass(main,"hidden");var search=document.getElementById("search");removeClass(search,"hidden");search.innerHTML=output;var tds=search.getElementsByTagName("td");var td_width=0;if(tds.length>0){td_width=tds[0].offsetWidth}var width=search.offsetWidth-40-td_width;onEachLazy(search.getElementsByClassName("desc"),function(e){e.style.width=width+"px"});initSearchNav();var elems=document.getElementById("titles").childNodes;elems[0].onclick=function(){printTab(0)};elems[1].onclick=function(){printTab(1)};elems[2].onclick=function(){printTab(2)};printTab(currentTab)}function execSearch(query,searchWords,filterCrates){function getSmallest(arrays,positions,notDuplicates){var start=null;for(var it=0;itpositions[it]&&(start===null||start>arrays[it][positions[it]].lev)&&!notDuplicates[arrays[it][positions[it]].fullPath]){start=arrays[it][positions[it]].lev}}return start}function mergeArrays(arrays){var ret=[];var positions=[];var notDuplicates={};for(var x=0;xpositions[x]&&arrays[x][positions[x]].lev===smallest&&!notDuplicates[arrays[x][positions[x]].fullPath]){ret.push(arrays[x][positions[x]]);notDuplicates[arrays[x][positions[x]].fullPath]=true;positions[x]+=1}}}return ret}var queries=query.raw.split(",");var results={"in_args":[],"returned":[],"others":[],};for(var i=0;i1){return{"in_args":mergeArrays(results.in_args),"returned":mergeArrays(results.returned),"others":mergeArrays(results.others),}}else{return{"in_args":results.in_args[0],"returned":results.returned[0],"others":results.others[0],}}}function getFilterCrates(){var elem=document.getElementById("crate-search");if(elem&&elem.value!=="All crates"&&rawSearchIndex.hasOwnProperty(elem.value)){return elem.value}return undefined}function search(e,forced){var params=getQueryStringParams();var query=getQuery(search_input.value.trim());if(e){e.preventDefault()}if(query.query.length===0){return}if(forced!==true&&query.id===currentResults){if(query.query.length>0){putBackSearch(search_input)}return}document.title="Results for "+query.query+" - Rust";if(browserSupportsHistoryApi()){if(!history.state&&!params.search){history.pushState(query,"","?search="+encodeURIComponent(query.raw))}else{history.replaceState(query,"","?search="+encodeURIComponent(query.raw))}}var filterCrates=getFilterCrates();showResults(execSearch(query,index,filterCrates),filterCrates)}function buildIndex(rawSearchIndex){searchIndex=[];var searchWords=[];var i;for(var crate in rawSearchIndex){if(!rawSearchIndex.hasOwnProperty(crate)){continue}searchWords.push(crate);searchIndex.push({crate:crate,ty:1,name:crate,path:"",desc:rawSearchIndex[crate].doc,type:null,});var items=rawSearchIndex[crate].i;var paths=rawSearchIndex[crate].p;var len=paths.length;for(i=0;i"+""+"
"+code.outerHTML+"
";list.appendChild(display)}}};if(window.pending_implementors){window.register_implementors(window.pending_implementors)}function labelForToggleButton(sectionIsCollapsed){if(sectionIsCollapsed){return"+"}return"\u2212"}function onEveryMatchingChild(elem,className,func){if(elem&&className&&func){var length=elem.childNodes.length;var nodes=elem.childNodes;for(var i=0;i"+labelForToggleButton(sectionIsCollapsed)+"
]";return toggle}var toggle=createSimpleToggle(false);var hideMethodDocs=getCurrentValue("rustdoc-method-docs")==="true";var pageId=getPageId();var func=function(e){var next=e.nextElementSibling;if(!next){return}if(hasClass(next,"docblock")===true||(hasClass(next,"stability")===true&&hasClass(next.nextElementSibling,"docblock")===true)){var newToggle=toggle.cloneNode(true);insertAfter(newToggle,e.childNodes[e.childNodes.length-1]);if(hideMethodDocs===true&&hasClass(e,"method")===true){collapseDocs(newToggle,"hide",pageId)}}};var funcImpl=function(e){var next=e.nextElementSibling;if(next&&hasClass(next,"docblock")){next=next.nextElementSibling}if(!next){return}if(next.getElementsByClassName("method").length>0&&hasClass(e,"impl")){insertAfter(toggle.cloneNode(true),e.childNodes[e.childNodes.length-1])}};onEachLazy(document.getElementsByClassName("method"),func);onEachLazy(document.getElementsByClassName("associatedconstant"),func);onEachLazy(document.getElementsByClassName("impl"),funcImpl);var impl_call=function(){};if(hideMethodDocs===true){impl_call=function(e,newToggle,pageId){if(e.id.match(/^impl(?:-\d+)?$/)===null){if(hasClass(e,"impl")===true){collapseDocs(newToggle,"hide",pageId)}}}}var newToggle=document.createElement("a");newToggle.href="javascript:void(0)";newToggle.className="collapse-toggle hidden-default collapsed";newToggle.innerHTML="["+labelForToggleButton(true)+"] Show hidden undocumented items";function toggleClicked(){if(hasClass(this,"collapsed")){removeClass(this,"collapsed");onEachLazy(this.parentNode.getElementsByClassName("hidden"),function(x){if(hasClass(x,"content")===false){removeClass(x,"hidden");addClass(x,"x")}},true);this.innerHTML="["+labelForToggleButton(false)+"] Hide undocumented items"}else{addClass(this,"collapsed");onEachLazy(this.parentNode.getElementsByClassName("x"),function(x){if(hasClass(x,"content")===false){addClass(x,"hidden");removeClass(x,"x")}},true);this.innerHTML="["+labelForToggleButton(true)+"] Show hidden undocumented items"}}onEachLazy(document.getElementsByClassName("impl-items"),function(e){onEachLazy(e.getElementsByClassName("associatedconstant"),func);var hiddenElems=e.getElementsByClassName("hidden");var needToggle=false;var hlength=hiddenElems.length;for(var i=0;i0){inner[0].innerHTML="+"}}if(extraClass){addClass(wrapper,extraClass)}wrapper.appendChild(mainToggle);return wrapper}var showItemDeclarations=getCurrentValue("rustdoc-item-declarations")==="false";function buildToggleWrapper(e){if(hasClass(e,"autohide")){var wrap=e.previousElementSibling;if(wrap&&hasClass(wrap,"toggle-wrapper")){var inner_toggle=wrap.childNodes[0];var extra=e.childNodes[0].tagName==="H3";e.style.display="none";addClass(wrap,"collapsed");onEachLazy(inner_toggle.getElementsByClassName("inner"),function(e){e.innerHTML=labelForToggleButton(true)});onEachLazy(inner_toggle.getElementsByClassName("toggle-label"),function(e){e.style.display="inline-block";if(extra===true){i_e.innerHTML=" Show "+e.childNodes[0].innerHTML}})}}if(e.parentNode.id==="main"){var otherMessage="";var fontSize;var extraClass;if(hasClass(e,"type-decl")){fontSize="20px";otherMessage=" Show declaration";if(showItemDeclarations===false){extraClass="collapsed"}}else if(hasClass(e,"sub-variant")){otherMessage=" Show fields"}else if(hasClass(e,"non-exhaustive")){otherMessage=" This ";if(hasClass(e,"non-exhaustive-struct")){otherMessage+="struct"}else if(hasClass(e,"non-exhaustive-enum")){otherMessage+="enum"}else if(hasClass(e,"non-exhaustive-variant")){otherMessage+="enum variant"}else if(hasClass(e,"non-exhaustive-type")){otherMessage+="type"}otherMessage+=" is marked as non-exhaustive"}else if(hasClass(e.childNodes[0],"impl-items")){extraClass="marg-left"}e.parentNode.insertBefore(createToggle(otherMessage,fontSize,extraClass,hasClass(e,"type-decl")===false||showItemDeclarations===true),e);if(hasClass(e,"type-decl")===true&&showItemDeclarations===true){collapseDocs(e.previousSibling.childNodes[0],"toggle")}if(hasClass(e,"non-exhaustive")===true){collapseDocs(e.previousSibling.childNodes[0],"toggle")}}}onEachLazy(document.getElementsByClassName("docblock"),buildToggleWrapper);onEachLazy(document.getElementsByClassName("sub-variant"),buildToggleWrapper);function createToggleWrapper(tog){var span=document.createElement("span");span.className="toggle-label";span.style.display="none";span.innerHTML=" Expand attributes";tog.appendChild(span);var wrapper=document.createElement("div");wrapper.className="toggle-wrapper toggle-attributes";wrapper.appendChild(tog);return wrapper}var itemAttributesFunc=function(){};if(getCurrentValue("rustdoc-item-attributes")!=="false"){itemAttributesFunc=function(x){collapseDocs(x.previousSibling.childNodes[0],"toggle")}}var attributesToggle=createToggleWrapper(createSimpleToggle(false));onEachLazy(main.getElementsByClassName("attributes"),function(i_e){var attr_tog=attributesToggle.cloneNode(true);if(hasClass(i_e,"top-attr")===true){addClass(attr_tog,"top-attr")}i_e.parentNode.insertBefore(attr_tog,i_e);itemAttributesFunc(i_e)});var lineNumbersFunc=function(){};if(getCurrentValue("rustdoc-line-numbers")==="true"){lineNumbersFunc=function(x){var count=x.textContent.split("\n").length;var elems=[];for(var i=0;i
✕"+"
"+content+"";document.getElementsByTagName("body")[0].appendChild(modal);document.getElementById("modal-close").onclick=hideModal;modal.onclick=hideModal}function hideModal(){var modal=document.getElementById("important");if(modal){modal.parentNode.removeChild(modal)}}onEachLazy(document.getElementsByClassName("important-traits"),function(e){e.onclick=function(){showModal(e.lastElementChild.innerHTML)}});function printTab(nb){if(nb===0||nb===1||nb===2){currentTab=nb}var nb_copy=nb;onEachLazy(document.getElementById("titles").childNodes,function(elem){if(nb_copy===0){addClass(elem,"selected")}else{removeClass(elem,"selected")}nb_copy-=1});onEachLazy(document.getElementById("results").childNodes,function(elem){if(nb===0){elem.style.display=""}else{elem.style.display="none"}nb-=1})}function putBackSearch(search_input){if(search_input.value!==""){addClass(main,"hidden");removeClass(document.getElementById("search"),"hidden");if(browserSupportsHistoryApi()){history.replaceState(search_input.value,"","?search="+encodeURIComponent(search_input.value))}}}if(search_input){search_input.onfocus=function(){putBackSearch(this)}}var params=getQueryStringParams();if(params&¶ms.search){addClass(main,"hidden");var search=document.getElementById("search");removeClass(search,"hidden");search.innerHTML="

Loading search results...

"}var sidebar_menu=document.getElementsByClassName("sidebar-menu")[0];if(sidebar_menu){sidebar_menu.onclick=function(){var sidebar=document.getElementsByClassName("sidebar")[0];if(hasClass(sidebar,"mobile")===true){hideSidebar()}else{showSidebar()}}}window.onresize=function(){hideSidebar()};autoCollapse(getPageId(),getCurrentValue("rustdoc-collapse")==="true");if(window.location.hash&&window.location.hash.length>0){expandSection(window.location.hash.replace(/^#/,""))}if(main){onEachLazy(main.getElementsByClassName("loading-content"),function(e){e.remove()});onEachLazy(main.childNodes,function(e){if(e.tagName==="H2"||e.tagName==="H3"){var nextTagName=e.nextElementSibling.tagName;if(nextTagName=="H2"||nextTagName=="H3"){e.nextElementSibling.style.display="flex"}else{e.nextElementSibling.style.display="block"}}})}function addSearchOptions(crates){var elem=document.getElementById('crate-search');if(!elem){return}var crates_text=[];if(Object.keys(crates).length>1){for(var crate in crates){if(crates.hasOwnProperty(crate)){crates_text.push(crate)}}}crates_text.sort(function(a,b){var lower_a=a.toLowerCase();var lower_b=b.toLowerCase();if(lower_alower_b){return 1}return 0});for(var i=0;iList of all items in this crate

[] + + List of all items

Functions

\ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/mylib/fn.add_one.html b/learn_crate1/mylib/target/doc/mylib/fn.add_one.html new file mode 100644 index 00000000..426978ca --- /dev/null +++ b/learn_crate1/mylib/target/doc/mylib/fn.add_one.html @@ -0,0 +1,8 @@ +mylib::add_one - Rust

[][src]Function mylib::add_one

pub fn add_one(x: i32) -> i32

Add one to the number given

+

#Example

+ +
+let five = 5;
+
+assert_eq!(6, mylib::add_one(5));
+
\ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/mylib/index.html b/learn_crate1/mylib/target/doc/mylib/index.html new file mode 100644 index 00000000..317eac74 --- /dev/null +++ b/learn_crate1/mylib/target/doc/mylib/index.html @@ -0,0 +1,5 @@ +mylib - Rust

[][src]Crate mylib

My Crate

+

'my_crate' is a collection of utilites to make performing certain calcuations more convenient

+

Functions

+
add_one

Add one to the number given

+
\ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/mylib/sidebar-items.js b/learn_crate1/mylib/target/doc/mylib/sidebar-items.js new file mode 100644 index 00000000..502cedfb --- /dev/null +++ b/learn_crate1/mylib/target/doc/mylib/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"fn":[["add_one","Add one to the number given "]]}); \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/normalize.css b/learn_crate1/mylib/target/doc/normalize.css new file mode 100644 index 00000000..45b6cb26 --- /dev/null +++ b/learn_crate1/mylib/target/doc/normalize.css @@ -0,0 +1,2 @@ +/*! normalize.css v3.0.0 | MIT License | git.io/normalize */ +html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/noscript.css b/learn_crate1/mylib/target/doc/noscript.css new file mode 100644 index 00000000..fa0b2c46 --- /dev/null +++ b/learn_crate1/mylib/target/doc/noscript.css @@ -0,0 +1 @@ +#main>h2+div,#main>h2+h3,#main>h3+div{display:block;}.loading-content{display:none;} \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/rust-logo.png b/learn_crate1/mylib/target/doc/rust-logo.png new file mode 100644 index 00000000..74b4bd69 Binary files /dev/null and b/learn_crate1/mylib/target/doc/rust-logo.png differ diff --git a/learn_crate1/mylib/target/doc/rustdoc.css b/learn_crate1/mylib/target/doc/rustdoc.css new file mode 100644 index 00000000..c0f75a46 --- /dev/null +++ b/learn_crate1/mylib/target/doc/rustdoc.css @@ -0,0 +1 @@ + @font-face {font-family:'Fira Sans';font-style:normal;font-weight:400;src:local('Fira Sans'),url("FiraSans-Regular.woff") format('woff');}@font-face {font-family:'Fira Sans';font-style:normal;font-weight:500;src:local('Fira Sans Medium'),url("FiraSans-Medium.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:normal;font-weight:400;src:local('Source Serif Pro'),url("SourceSerifPro-Regular.ttf.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:italic;font-weight:400;src:local('Source Serif Pro Italic'),url("SourceSerifPro-It.ttf.woff") format('woff');}@font-face {font-family:'Source Serif Pro';font-style:normal;font-weight:700;src:local('Source Serif Pro Bold'),url("SourceSerifPro-Bold.ttf.woff") format('woff');}@font-face {font-family:'Source Code Pro';font-style:normal;font-weight:400;src:url("SourceCodePro-Regular.woff") format('woff');}@font-face {font-family:'Source Code Pro';font-style:normal;font-weight:600;src:url("SourceCodePro-Semibold.woff") format('woff');}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}body{font:16px/1.4 "Source Serif Pro",serif;margin:0;position:relative;padding:10px 15px 20px 15px;-webkit-font-feature-settings:"kern","liga";-moz-font-feature-settings:"kern","liga";font-feature-settings:"kern","liga";}h1{font-size:1.5em;}h2{font-size:1.4em;}h3{font-size:1.3em;}h1,h2,h3:not(.impl):not(.method):not(.type):not(.tymethod):not(.important),h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){font-weight:500;margin:20px 0 15px 0;padding-bottom:6px;}h1.fqn{border-bottom:1px dashed;margin-top:0;}h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant){border-bottom:1px solid;}h3.impl,h3.method,h4.method,h3.type,h4.type,h4.associatedconstant{flex-basis:100%;font-weight:600;margin-top:16px;margin-bottom:10px;position:relative;}h3.impl,h3.method,h3.type{padding-left:15px;}h1,h2,h3,h4,.sidebar,a.source,.search-input,.content table :not(code)>a,.collapse-toggle,div.item-list .out-of-band,#source-sidebar,#sidebar-toggle{font-family:"Fira Sans",sans-serif;}ol,ul{padding-left:25px;}ul ul,ol ul,ul ol,ol ol{margin-bottom:.6em;}p{margin:0 0 .6em 0;}summary{outline:none;}code,pre{font-family:"Source Code Pro",monospace;}.docblock code,.docblock-short code{border-radius:3px;padding:0 0.1em;}.docblock pre code,.docblock-short pre code,.docblock code.spotlight{padding:0;}.docblock code.spotlight :last-child{padding-bottom:0.6em;}pre{padding:14px;}.source .content pre{padding:20px;}img{max-width:100%;}li{position:relative;}.source .content{margin-top:50px;max-width:none;overflow:visible;margin-left:0px;min-width:70em;}nav.sub{font-size:16px;text-transform:uppercase;}.sidebar{width:200px;position:fixed;left:0;top:0;height:100vh;overflow:auto;}.sidebar .block>ul>li{margin-right:-10px;}.content,nav{max-width:960px;}.js-only,.hidden{display:none !important;}.logo-container{height:100px;width:100px;position:relative;margin:20px auto;display:block;margin-top:10px;}.logo-container>img{max-width:100px;max-height:100px;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:block;}.sidebar .location{border:1px solid;font-size:17px;margin:30px 10px 20px 10px;text-align:center;word-wrap:break-word;}.sidebar .version{font-size:15px;text-align:center;border-bottom:1px solid;overflow-wrap:break-word;word-wrap:break-word;word-break:break-word;}.location:empty{border:none;}.location a:first-child{font-weight:500;}.block{padding:0;margin-bottom:14px;}.block h2,.block h3{margin-top:0;margin-bottom:8px;text-align:center;}.block ul,.block li{margin:0 10px;padding:0;list-style:none;}.block a{display:block;text-overflow:ellipsis;overflow:hidden;line-height:15px;padding:7px 5px;font-size:14px;font-weight:300;transition:border 500ms ease-out;}.sidebar-title{border-top:1px solid;border-bottom:1px solid;text-align:center;font-size:17px;margin-bottom:5px;}.sidebar-links{margin-bottom:15px;}.sidebar-links>a{padding-left:10px;width:100%;}.sidebar-menu{display:none;}.content{padding:15px 0;}.source .content pre.rust{white-space:pre;overflow:auto;padding-left:0;}.rustdoc:not(.source) .example-wrap{display:inline-flex;margin-bottom:10px;}.example-wrap{width:100%;}.example-wrap>pre.line-number{overflow:initial;border:1px solid;border-top-left-radius:5px;border-bottom-left-radius:5px;padding:13px 8px;text-align:right;}.rustdoc:not(.source) .example-wrap>pre.rust{width:100%;overflow-x:auto;}.rustdoc:not(.source) .example-wrap>pre{margin:0;}#search{margin-left:230px;position:relative;}#results{position:absolute;right:0;left:0;overflow:auto;}#results>table{width:100%;table-layout:fixed;}.content pre.line-numbers{float:left;border:none;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}.line-numbers span{cursor:pointer;}.docblock-short p{display:inline;}.docblock-short.nowrap{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}.docblock-short p{overflow:hidden;text-overflow:ellipsis;margin:0;}.docblock-short code{white-space:pre-wrap;}.docblock h1,.docblock h2,.docblock h3,.docblock h4,.docblock h5{border-bottom:1px solid;}#main>.docblock h1{font-size:1.3em;}#main>.docblock h2{font-size:1.15em;}#main>.docblock h3,#main>.docblock h4,#main>.docblock h5{font-size:1em;}#main>h2+div,#main>h2+h3,#main>h3+div{display:none;flex-wrap:wrap;}.docblock h1{font-size:1em;}.docblock h2{font-size:0.95em;}.docblock h3,.docblock h4,.docblock h5{font-size:0.9em;}.docblock{margin-left:24px;position:relative;}.content .out-of-band{float:right;font-size:23px;margin:0px;padding:0px;font-weight:normal;}h3.impl>.out-of-band{font-size:21px;}h4.method>.out-of-band{font-size:19px;}h4>code,h3>code,.invisible>code{max-width:calc(100% - 41px);display:block;}.invisible{width:100%;display:inline-block;}.content .in-band{margin:0px;padding:0px;}.in-band>code{display:inline-block;}#main{position:relative;}#main>.since{top:inherit;font-family:"Fira Sans",sans-serif;}.content table:not(.table-display){border-spacing:0 5px;}.content td{vertical-align:top;}.content td:first-child{padding-right:20px;}.content td p:first-child{margin-top:0;}.content td h1,.content td h2{margin-left:0;font-size:1.1em;}.content tr:first-child td{border-top:0;}.docblock table{margin:.5em 0;width:calc(100% - 2px);border:1px dashed;}.docblock table td{padding:.5em;border:1px dashed;}.docblock table th{padding:.5em;text-align:left;border:1px solid;}.fields+table{margin-bottom:1em;}.content .item-list{list-style-type:none;padding:0;}.content .multi-column{-moz-column-count:5;-moz-column-gap:2.5em;-webkit-column-count:5;-webkit-column-gap:2.5em;column-count:5;column-gap:2.5em;}.content .multi-column li{width:100%;display:inline-block;}.content .method{font-size:1em;position:relative;}.content .method .where,.content .fn .where,.content .where.fmt-newline{display:block;font-size:0.8em;}.content .methods>div:not(.important-traits){margin-left:40px;margin-bottom:15px;}.content .docblock>.impl-items{margin-left:20px;margin-top:-34px;}.content .docblock>.impl-items>h4{border-bottom:0;}.content .docblock>.impl-items .table-display{margin:0;}.content .docblock>.impl-items table td{padding:0;}.toggle-wrapper.marg-left>.collapse-toggle{left:-24px;}.content .docblock>.impl-items .table-display,.impl-items table td{border:none;}.content .stability code{font-size:90%;}.content .stability{position:relative;margin-left:33px;margin-top:-13px;}.sub-variant>div>.stability{margin-top:initial;}.content .stability::before{content:'˪';font-size:30px;position:absolute;top:-9px;left:-13px;}.content .impl-items .method,.content .impl-items>.type,.impl-items>.associatedconstant{margin-left:20px;}.content .impl-items .docblock,.content .impl-items .stability{margin-bottom:.6em;}.content .impl-items>.stability{margin-left:40px;}.methods>.stability,.content .impl-items>.stability{margin-top:-8px;}.impl-items{flex-basis:100%;}#main>.stability{margin-top:0;}nav{border-bottom:1px solid;padding-bottom:10px;margin-bottom:10px;}nav.main{padding:20px 0;text-align:center;}nav.main .current{border-top:1px solid;border-bottom:1px solid;}nav.main .separator{border:1px solid;display:inline-block;height:23px;margin:0 20px;}nav.sum{text-align:right;}nav.sub form{display:inline;}nav.sub,.content{margin-left:230px;}a{text-decoration:none;background:transparent;}.small-section-header:hover>.anchor{display:initial;}.in-band:hover>.anchor{display:inline-block;position:absolute;}.anchor{display:none;position:absolute;left:-7px;}.anchor.field{left:-5px;}.small-section-header>.anchor{left:-28px;padding-right:10px;}.anchor:before{content:'\2002\00a7\2002';}.docblock a:not(.srclink):not(.test-arrow):hover,.docblock-short a:not(.srclink):not(.test-arrow):hover,.stability a{text-decoration:underline;}.invisible>.srclink,h4>code+.srclink{position:absolute;top:0;right:0;font-size:17px;font-weight:normal;}.block a.current.crate{font-weight:500;}.search-container{position:relative;}.search-container>div{display:inline-flex;width:calc(100% - 34px);}#crate-search{margin-top:5px;padding:6px;padding-right:19px;flex:none;border:0;border-right:0;border-radius:4px 0 0 4px;outline:none;cursor:pointer;border-right:1px solid;-moz-appearance:none;-webkit-appearance:none;text-indent:0.01px;text-overflow:"";background-repeat:no-repeat;background-color:transparent;background-size:20px;background-position:calc(100% - 1px) 56%;}.search-container>.top-button{position:absolute;right:0;top:10px;}.search-input{-moz-box-sizing:border-box !important;box-sizing:border-box !important;outline:none;border:none;border-radius:1px;margin-top:5px;padding:10px 16px;font-size:17px;transition:border-color 300ms ease;transition:border-radius 300ms ease-in-out;transition:box-shadow 300ms ease-in-out;width:100%;}#crate-search+.search-input{border-radius:0 1px 1px 0;width:calc(100% - 32px);}.search-input:focus{border-radius:2px;border:0;outline:0;}.search-results .desc{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;display:block;}.search-results a{display:block;}.content .search-results td:first-child{padding-right:0;width:50%;}.content .search-results td:first-child a{padding-right:10px;}.content .search-results td:first-child a:after{clear:both;content:"";display:block;}.content .search-results td:first-child a span{float:left;}tr.result span.primitive::after{content:' (primitive type)';font-style:italic;}tr.result span.keyword::after{content:' (keyword)';font-style:italic;}body.blur>:not(#help){filter:blur(8px);-webkit-filter:blur(8px);opacity:.7;}#help{width:100%;height:100vh;position:fixed;top:0;left:0;display:flex;justify-content:center;align-items:center;}#help>div{flex:0 0 auto;box-shadow:0 0 6px rgba(0,0,0,.2);width:550px;height:auto;border:1px solid;}#help dt{float:left;clear:left;display:block;}#help dd{margin:5px 35px;}#help .infos{padding-left:0;}#help h1,#help h2{margin-top:0;}#help>div div{width:50%;float:left;padding:20px;padding-left:17px;}.stab{display:table;border-width:1px;border-style:solid;padding:3px;margin-bottom:5px;font-size:90%;}.stab p{display:inline;}.stab summary{display:list-item;}.stab .emoji{font-size:1.5em;}.module-item .stab{border-radius:3px;display:inline-block;font-size:80%;line-height:1.2;margin-bottom:0;margin-right:.3em;padding:2px;vertical-align:text-bottom;}.module-item.unstable{opacity:0.65;}.since{font-weight:normal;font-size:initial;position:absolute;right:0;top:0;}.impl-items .since,.impl .since{flex-grow:0;padding-left:12px;padding-right:2px;position:initial;}.impl-items .srclink,.impl .srclink{flex-grow:0;font-size:17px;font-weight:normal;}.impl-items code,.impl code{flex-grow:1;}.impl-items h4,h4.impl,h3.impl{display:flex;flex-basis:100%;font-size:16px;margin-bottom:12px;justify-content:space-between;}.variants_table{width:100%;}.variants_table tbody tr td:first-child{width:1%;}td.summary-column{width:100%;}.summary{padding-right:0px;}pre.rust .question-mark{font-weight:bold;}a.test-arrow{display:inline-block;position:absolute;padding:5px 10px 5px 10px;border-radius:5px;font-size:130%;top:5px;right:5px;}a.test-arrow:hover{text-decoration:none;}.section-header:hover a:before{position:absolute;left:-25px;padding-right:10px;content:'\2002\00a7\2002';}.section-header:hover a{text-decoration:none;}.section-header a{color:inherit;}.collapse-toggle{font-weight:300;position:absolute;left:-23px;top:0;}h3>.collapse-toggle,h4>.collapse-toggle{font-size:0.8em;top:5px;}.toggle-wrapper>.collapse-toggle{left:-24px;margin-top:0px;}.toggle-wrapper{position:relative;margin-top:0;}.toggle-wrapper.collapsed{height:25px;transition:height .2s;margin-bottom:.6em;}.collapse-toggle>.inner{display:inline-block;width:1.2ch;text-align:center;}.collapse-toggle.hidden-default{position:relative;margin-left:20px;}.since+.srclink{display:table-cell;padding-left:10px;}.item-spacer{width:100%;height:12px;}.out-of-band>span.since{position:initial;font-size:20px;margin-right:5px;}.toggle-wrapper>.collapse-toggle{left:0;}.variant+.toggle-wrapper+.docblock>p{margin-top:5px;}.sub-variant,.sub-variant>h3{margin-top:1px !important;}#main>.sub-variant>h3{font-size:15px;margin-left:25px;margin-bottom:5px;}.sub-variant>div{margin-left:20px;margin-bottom:10px;}.sub-variant>div>span{display:block;position:relative;}.toggle-label{display:inline-block;margin-left:4px;margin-top:3px;}.enum>.toggle-wrapper+.docblock,.struct>.toggle-wrapper+.docblock{margin-left:30px;margin-bottom:20px;margin-top:5px;}.docblock>.section-header:first-child{margin-left:15px;margin-top:0;}.docblock>.section-header:first-child:hover>a:before{left:-10px;}.enum>.collapsed,.struct>.collapsed{margin-bottom:25px;}#main>.variant,#main>.structfield{display:block;}.attributes{display:block;margin-top:0px !important;margin-right:0px;margin-bottom:0px !important;margin-left:30px;}.toggle-attributes.collapsed{margin-bottom:0;}.impl-items>.toggle-attributes{margin-left:20px;}.impl-items .attributes{font-weight:500;}:target>code{opacity:1;}.information{position:absolute;left:-20px;margin-top:7px;z-index:1;}.tooltip{position:relative;display:inline-block;cursor:pointer;}.tooltip .tooltiptext{width:120px;display:none;text-align:center;padding:5px 3px;border-radius:6px;margin-left:5px;top:-5px;left:105%;z-index:10;}.tooltip:hover .tooltiptext{display:inline;}.tooltip .tooltiptext::after{content:" ";position:absolute;top:50%;left:11px;margin-top:-5px;border-width:5px;border-style:solid;}.important-traits .tooltip .tooltiptext{border:1px solid;}pre.rust{position:relative;tab-width:4;-moz-tab-width:4;}.search-failed{text-align:center;margin-top:20px;}.search-failed>ul{text-align:left;max-width:570px;margin-left:auto;margin-right:auto;}#titles{height:35px;}#titles>div{float:left;width:33.3%;text-align:center;font-size:18px;cursor:pointer;border-top:2px solid;}#titles>div:not(:last-child){margin-right:1px;width:calc(33.3% - 1px);}#titles>div>div.count{display:inline-block;font-size:16px;}.important-traits{cursor:pointer;z-index:2;}h4>.important-traits{position:absolute;left:-44px;top:2px;}#all-types{text-align:center;border:1px solid;margin:0 10px;margin-bottom:10px;display:block;border-radius:7px;}#all-types>p{margin:5px 0;}#sidebar-toggle{position:fixed;top:30px;left:300px;z-index:10;padding:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;cursor:pointer;font-weight:bold;transition:left .5s;font-size:1.2em;border:1px solid;border-left:0;}#source-sidebar{position:fixed;top:0;bottom:0;left:0;width:300px;z-index:1;overflow:auto;transition:left .5s;border-right:1px solid;}#source-sidebar>.title{font-size:1.5em;text-align:center;border-bottom:1px solid;margin-bottom:6px;}.theme-picker{position:absolute;left:211px;top:19px;}.theme-picker button{outline:none;}#settings-menu{position:absolute;right:0;top:10px;outline:none;}#theme-picker,#settings-menu{padding:4px;width:27px;height:29px;border:1px solid;border-radius:3px;cursor:pointer;}#theme-choices{display:none;position:absolute;left:0;top:28px;border:1px solid;border-radius:3px;z-index:1;cursor:pointer;}#theme-choices>button{border:none;width:100%;padding:4px;text-align:center;background:rgba(0,0,0,0);}#theme-choices>button:not(:first-child){border-top:1px solid;}@media (max-width:700px){body{padding-top:0px;}.rustdoc>.sidebar{height:45px;min-height:40px;margin:0;margin-left:-15px;padding:0 15px;position:static;z-index:11;}.sidebar>.location{float:right;margin:0px;margin-top:2px;padding:3px 10px 1px 10px;min-height:39px;background:inherit;text-align:left;font-size:24px;}.sidebar .location:empty{padding:0;}.sidebar .logo-container{width:35px;height:35px;margin-top:5px;margin-bottom:5px;float:left;margin-left:50px;}.sidebar .logo-container>img{max-width:35px;max-height:35px;}.sidebar-menu{position:fixed;z-index:10;font-size:2rem;cursor:pointer;width:45px;left:0;text-align:center;display:block;border-bottom:1px solid;border-right:1px solid;height:45px;}.rustdoc.source>.sidebar>.sidebar-menu{display:none;}.sidebar-elems{position:fixed;z-index:1;left:0;top:45px;bottom:0;overflow-y:auto;border-right:1px solid;display:none;}.sidebar>.block.version{border-bottom:none;margin-top:12px;}nav.sub{width:calc(100% - 32px);float:right;}.content{margin-left:0px;}#main{margin-top:45px;padding:0;}.content .in-band{width:100%;}.content h4>.out-of-band{position:inherit;}.toggle-wrapper>.collapse-toggle{left:0px;}.toggle-wrapper{height:1.5em;}#search{margin-left:0;}.content .impl-items .method,.content .impl-items>.type,.impl-items>.associatedconstant{display:flex;}.anchor{display:none !important;}h1.fqn{overflow:initial;}.theme-picker{left:10px;top:54px;z-index:1;}h4>.important-traits{position:absolute;left:-22px;top:24px;}#titles>div>div.count{float:left;width:100%;}#titles{height:50px;}.sidebar.mobile{position:fixed;width:100%;margin-left:0;background-color:rgba(0,0,0,0);height:100%;}.sidebar{width:calc(100% + 30px);}.show-it{display:block;width:246px;}.show-it>.block.items{margin:8px 0;}.show-it>.block.items>ul{margin:0;}.show-it>.block.items>ul>li{text-align:center;margin:2px 0;}.show-it>.block.items>ul>li>a{font-size:21px;}#sidebar-filler{position:fixed;left:45px;width:calc(100% - 45px);top:0;height:45px;z-index:-1;border-bottom:1px solid;}.collapse-toggle{left:-20px;}.impl>.collapse-toggle{left:-10px;}#all-types{margin:10px;}#sidebar-toggle{top:100px;width:30px;font-size:1.5rem;text-align:center;padding:0;}#source-sidebar{z-index:11;}#main>.line-numbers{margin-top:0;}}@media print{nav.sub,.content .out-of-band,.collapse-toggle{display:none;}}@media (max-width:416px){#titles{height:73px;}#titles>div{height:73px;}}.modal{position:fixed;width:100vw;height:100vh;z-index:10000;top:0;left:0;}.modal-content{display:block;max-width:60%;min-width:200px;padding:8px;top:40%;position:absolute;left:50%;transform:translate(-50%,-40%);border:1px solid;border-radius:4px;border-top-right-radius:0;}.modal-content>.docblock{margin:0;}h3.important{margin:0;margin-bottom:13px;font-size:19px;}.modal-content>.docblock>code.content{margin:0;padding:0;font-size:20px;}.modal-content>.close{position:absolute;font-weight:900;right:-25px;top:-1px;font-size:18px;width:25px;padding-right:2px;border-top-right-radius:5px;border-bottom-right-radius:5px;text-align:center;border:1px solid;border-right:0;cursor:pointer;}.modal-content>.whiter{height:25px;position:absolute;width:3px;right:-2px;top:0px;}#main>div.important-traits{position:absolute;left:-24px;margin-top:16px;}.content>.methods>.method>div.important-traits{position:absolute;font-weight:400;left:-42px;margin-top:2px;}kbd{display:inline-block;padding:3px 5px;font:15px monospace;line-height:10px;vertical-align:middle;border:solid 1px;border-radius:3px;box-shadow:inset 0 -1px 0;cursor:default;}.hidden-by-impl-hider,.hidden-by-usual-hider{display:none !important;}#implementations-list>h3>span.in-band{width:100%;}.table-display{width:100%;border:0;border-collapse:collapse;border-spacing:0;font-size:16px;}.table-display tr td:first-child{padding-right:0;}.table-display tr td:last-child{float:right;}.table-display .out-of-band{position:relative;font-size:19px;display:block;}#implementors-list>.impl-items .table-display .out-of-band{font-size:17px;}.table-display td:hover .anchor{display:block;top:2px;left:-5px;}#main>ul{padding-left:10px;}#main>ul>li{list-style:none;}.non-exhaustive{margin-bottom:1em;}div.children{padding-left:27px;display:none;}div.name{cursor:pointer;position:relative;margin-left:16px;}div.files>a{display:block;padding:0 3px;}div.files>a:hover,div.name:hover{background-color:#a14b4b;}div.name.expand+.children{display:block;}div.name::before{content:"\25B6";padding-left:4px;font-size:0.7em;position:absolute;left:-16px;top:4px;}div.name.expand::before{transform:rotate(90deg);left:-15px;top:2px;}.type-decl>pre>.toggle-wrapper.toggle-attributes.top-attr{margin-left:0 !important;}.type-decl>pre>.docblock.attributes.top-attr{margin-left:1.8em !important;}.type-decl>pre>.toggle-attributes{margin-left:2.2em;}.type-decl>pre>.docblock.attributes{margin-left:4em;} \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/search-index.js b/learn_crate1/mylib/target/doc/search-index.js new file mode 100644 index 00000000..e320771a --- /dev/null +++ b/learn_crate1/mylib/target/doc/search-index.js @@ -0,0 +1,4 @@ +var N=null,E="",T="t",U="u",searchIndex={}; + +searchIndex["mylib"]={"doc":"My Crate","i":[[5,"add_one","mylib","Add one to the number given ",N,[[["i32"]],["i32"]]]],"p":[]}; +initSearch(searchIndex);addSearchOptions(searchIndex); \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/settings.css b/learn_crate1/mylib/target/doc/settings.css new file mode 100644 index 00000000..4201b266 --- /dev/null +++ b/learn_crate1/mylib/target/doc/settings.css @@ -0,0 +1 @@ +.setting-line{padding:5px;}.setting-line>div{max-width:calc(100% - 74px);display:inline-block;vertical-align:top;font-size:17px;padding-top:2px;}.toggle{position:relative;display:inline-block;width:45px;height:27px;margin-right:20px;}.toggle input{display:none;}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.3s;transition:.3s;}.slider:before{position:absolute;content:"";height:19px;width:19px;left:4px;bottom:4px;background-color:white;-webkit-transition:.3s;transition:.3s;}input:checked+.slider{background-color:#2196F3;}input:focus+.slider{box-shadow:0 0 1px #2196F3;}input:checked+.slider:before{-webkit-transform:translateX(19px);-ms-transform:translateX(19px);transform:translateX(19px);} \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/settings.html b/learn_crate1/mylib/target/doc/settings.html new file mode 100644 index 00000000..bde3d6dc --- /dev/null +++ b/learn_crate1/mylib/target/doc/settings.html @@ -0,0 +1 @@ +Rustdoc settings

Rustdoc settings

Auto-hide item declarations.
Auto-hide item attributes.
Auto-hide trait implementations documentation
Auto-hide item methods' documentation
Directly go to item in search if there is only one result
Show line numbers on code examples
\ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/settings.js b/learn_crate1/mylib/target/doc/settings.js new file mode 100644 index 00000000..99303090 --- /dev/null +++ b/learn_crate1/mylib/target/doc/settings.js @@ -0,0 +1 @@ +(function(){function changeSetting(settingName,isEnabled){updateLocalStorage('rustdoc-'+settingName,isEnabled)}function getSettingValue(settingName){return getCurrentValue('rustdoc-'+settingName)}function setEvents(){var elems=document.getElementsByClassName("slider");if(!elems||elems.length===0){return}for(var i=0;i"){sidebar.style.left="";this.style.left="";child.innerText="<";updateLocalStorage("rustdoc-source-sidebar-show","true")}else{sidebar.style.left="-300px";this.style.left="0";child.innerText=">";updateLocalStorage("rustdoc-source-sidebar-show","false")}}function createSidebarToggle(){var sidebarToggle=document.createElement("div");sidebarToggle.id="sidebar-toggle";sidebarToggle.onclick=toggleSidebar;var inner1=document.createElement("div");inner1.style.position="relative";var inner2=document.createElement("div");inner2.style.paddingTop="3px";if(getCurrentValue("rustdoc-source-sidebar-show")==="true"){inner2.innerText="<"}else{inner2.innerText=">";sidebarToggle.style.left="0"}inner1.appendChild(inner2);sidebarToggle.appendChild(inner1);return sidebarToggle}function createSourceSidebar(){if(window.rootPath.endsWith("/")===false){window.rootPath+="/"}var main=document.getElementById("main");var sidebarToggle=createSidebarToggle();main.insertBefore(sidebarToggle,main.firstChild);var sidebar=document.createElement("div");sidebar.id="source-sidebar";if(getCurrentValue("rustdoc-source-sidebar-show")!=="true"){sidebar.style.left="-300px"}var currentFile=getCurrentFilePath();var hasFoundFile=false;var title=document.createElement("div");title.className="title";title.innerText="Files";sidebar.appendChild(title);Object.keys(sourcesIndex).forEach(function(key){sourcesIndex[key].name=key;hasFoundFile=createDirEntry(sourcesIndex[key],sidebar,"",currentFile,hasFoundFile)});main.insertBefore(sidebar,main.firstChild)} \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/src/mylib/lib.rs.html b/learn_crate1/mylib/target/doc/src/mylib/lib.rs.html new file mode 100644 index 00000000..ebe6aa76 --- /dev/null +++ b/learn_crate1/mylib/target/doc/src/mylib/lib.rs.html @@ -0,0 +1,71 @@ +lib.rs.html -- source
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+
+//! My Crate
+//! 
+//! 'my_crate' is a collection of utilites to make performing certain calcuations more convenient
+//!
+/// Add one to the number given 
+/// 
+/// #Example
+///
+/// ```
+/// let five = 5;
+///
+/// assert_eq!(6, mylib::add_one(5));
+/// ```
+pub fn add_one(x: i32) -> i32 {
+    x + 1
+}
+
+
+
+
+
+
+
+
+
+
+
+//#[cfg(test)]
+//mod tests {
+//    #[test]
+//    fn it_works() {
+//        assert_eq!(2 + 2, 4);
+//    }
+//}
+
+
\ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/storage.js b/learn_crate1/mylib/target/doc/storage.js new file mode 100644 index 00000000..e19a00ab --- /dev/null +++ b/learn_crate1/mylib/target/doc/storage.js @@ -0,0 +1 @@ +var resourcesSuffix="";var currentTheme=document.getElementById("themeStyle");var mainTheme=document.getElementById("mainThemeStyle");var savedHref=[];function hasClass(elem,className){return elem&&elem.classList&&elem.classList.contains(className)}function addClass(elem,className){if(!elem||!elem.classList){return}elem.classList.add(className)}function removeClass(elem,className){if(!elem||!elem.classList){return}elem.classList.remove(className)}function isHidden(elem){return elem.offsetParent===null}function onEach(arr,func,reversed){if(arr&&arr.length>0&&func){var length=arr.length;if(reversed!==true){for(var i=0;i=0;--i){if(func(arr[i])===true){return true}}}}return false}function onEachLazy(lazyArray,func,reversed){return onEach(Array.prototype.slice.call(lazyArray),func,reversed)}function usableLocalStorage(){if(typeof(Storage)==="undefined"){return false}try{return window.localStorage!==null&&window.localStorage!==undefined}catch(err){return false}}function updateLocalStorage(name,value){if(usableLocalStorage()){localStorage[name]=value}else{}}function getCurrentValue(name){if(usableLocalStorage()&&localStorage[name]!==undefined){return localStorage[name]}return null}function switchTheme(styleElem,mainStyleElem,newTheme){var fullBasicCss="rustdoc"+resourcesSuffix+".css";var fullNewTheme=newTheme+resourcesSuffix+".css";var newHref=mainStyleElem.href.replace(fullBasicCss,fullNewTheme);if(styleElem.href===newHref){return}var found=false;if(savedHref.length===0){onEachLazy(document.getElementsByTagName("link"),function(el){savedHref.push(el.href)})}onEach(savedHref,function(el){if(el===newHref){found=true;return true}});if(found===true){styleElem.href=newHref;updateLocalStorage("rustdoc-theme",newTheme)}}switchTheme(currentTheme,mainTheme,getCurrentValue("rustdoc-theme")||"light") \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/theme.js b/learn_crate1/mylib/target/doc/theme.js new file mode 100644 index 00000000..25d23fcc --- /dev/null +++ b/learn_crate1/mylib/target/doc/theme.js @@ -0,0 +1,47 @@ +var themes = document.getElementById("theme-choices"); +var themePicker = document.getElementById("theme-picker"); + +function showThemeButtonState() { + themes.style.display = "none"; + themePicker.style.borderBottomRightRadius = "3px"; + themePicker.style.borderBottomLeftRadius = "3px"; +} + +function hideThemeButtonState() { + themes.style.display = "block"; + themePicker.style.borderBottomRightRadius = "0"; + themePicker.style.borderBottomLeftRadius = "0"; +} + +function switchThemeButtonState() { + if (themes.style.display === "block") { + showThemeButtonState(); + } else { + hideThemeButtonState(); + } +}; + +function handleThemeButtonsBlur(e) { + var active = document.activeElement; + var related = e.relatedTarget; + + if (active.id !== "themePicker" && + (!active.parentNode || active.parentNode.id !== "theme-choices") && + (!related || + (related.id !== "themePicker" && + (!related.parentNode || related.parentNode.id !== "theme-choices")))) { + hideThemeButtonState(); + } +} + +themePicker.onclick = switchThemeButtonState; +themePicker.onblur = handleThemeButtonsBlur; +["dark","light"].forEach(function(item) { + var but = document.createElement('button'); + but.innerHTML = item; + but.onclick = function(el) { + switchTheme(currentTheme, mainTheme, item); + }; + but.onblur = handleThemeButtonsBlur; + themes.appendChild(but); +}); \ No newline at end of file diff --git a/learn_crate1/mylib/target/doc/wheel.svg b/learn_crate1/mylib/target/doc/wheel.svg new file mode 100644 index 00000000..44381a40 --- /dev/null +++ b/learn_crate1/mylib/target/doc/wheel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/learn_crate1/src/main.rs b/learn_crate1/src/main.rs new file mode 100644 index 00000000..af4b9388 --- /dev/null +++ b/learn_crate1/src/main.rs @@ -0,0 +1,9 @@ +use crypto::digest::Digest; +use crypto::sha3::Sha3; + +fn main() { + let mut hasher = Sha3::sha3_256(); + hasher.input_str("Hello world!"); + let result = hasher.result_str(); + println!("result: {}", result); +} diff --git a/learn_crate1/tt b/learn_crate1/tt new file mode 100644 index 00000000..749184c9 --- /dev/null +++ b/learn_crate1/tt @@ -0,0 +1,12 @@ +crate的发布与撤回(此部分没有实际操作过,只讲步骤) +(1)创建Crates.io账号:通过Github账户注册,并通过cargo login ****** 来登陆 +(2)发布前需要在Cargo.toml中增加描述: +[package] +name = "package_name" +version = "0.1.0" +license = "MIT" #Linux 基金会 的 Software Package Data Exchange (SPDX) 列出了可以使用的标识符 +authors = ["linghuyichong"] +description = "some thing descript the package" +运行cargo publish来发布。 +(3)撤回指定版本 +cargo yank --vers 0.1.0 diff --git a/learn_crate2/.gitignore b/learn_crate2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_crate2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_crate2/Cargo.lock b/learn_crate2/Cargo.lock new file mode 100644 index 00000000..8c9124a4 --- /dev/null +++ b/learn_crate2/Cargo.lock @@ -0,0 +1,13 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_crate2" +version = "0.1.0" +dependencies = [ + "mylib 0.1.0", +] + +[[package]] +name = "mylib" +version = "0.1.0" + diff --git a/learn_crate2/Cargo.toml b/learn_crate2/Cargo.toml new file mode 100644 index 00000000..b32e7b5d --- /dev/null +++ b/learn_crate2/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "learn_crate2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +mylib = {path = "./mylib"} diff --git a/learn_crate2/mylib/Cargo.toml b/learn_crate2/mylib/Cargo.toml new file mode 100644 index 00000000..2e9d8c26 --- /dev/null +++ b/learn_crate2/mylib/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "mylib" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_crate2/mylib/src/factory.rs b/learn_crate2/mylib/src/factory.rs new file mode 100644 index 00000000..94813fce --- /dev/null +++ b/learn_crate2/mylib/src/factory.rs @@ -0,0 +1,16 @@ +pub mod produce_refrigerator { + pub fn produce_re() { + println!("produce refrigerator!"); + } +} + +pub mod produce_washing_machine { + pub fn produce_washing() { + println!("produce washing machine!"); + } + + pub fn produce_re() { + println!("produce washing machine!"); + } +} + diff --git a/learn_crate2/mylib/src/lib.rs b/learn_crate2/mylib/src/lib.rs new file mode 100644 index 00000000..c888dcdd --- /dev/null +++ b/learn_crate2/mylib/src/lib.rs @@ -0,0 +1,9 @@ +pub mod factory; + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} diff --git a/learn_crate2/src/main.rs b/learn_crate2/src/main.rs new file mode 100644 index 00000000..5a1a85f7 --- /dev/null +++ b/learn_crate2/src/main.rs @@ -0,0 +1,15 @@ +//use mylib::factory::produce_refrigerator; +////use mylib::factory::produce_refrigerator::produce_re; +////use mylib::factory::produce_washing_machine; +//use mylib::factory::produce_washing_machine as A; + +use mylib::factory::*; + +fn main() { + mylib::factory::produce_refrigerator::produce_re(); //绝对路径 + produce_refrigerator::produce_re(); //使用use + produce_washing_machine::produce_re(); + //A::produce_re(); + + println!("Hello, world!"); +} diff --git a/learn_crate3/.gitignore b/learn_crate3/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_crate3/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_crate3/Cargo.lock b/learn_crate3/Cargo.lock new file mode 100644 index 00000000..ee4b53c1 --- /dev/null +++ b/learn_crate3/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_crate3" +version = "0.1.0" + diff --git a/learn_crate3/Cargo.toml b/learn_crate3/Cargo.toml new file mode 100644 index 00000000..7aefb9c5 --- /dev/null +++ b/learn_crate3/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_crate3" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_crate3/src/main.rs b/learn_crate3/src/main.rs new file mode 100644 index 00000000..b4d51cb8 --- /dev/null +++ b/learn_crate3/src/main.rs @@ -0,0 +1,49 @@ +mod modA { + #[derive(Debug)] + pub struct A { + pub number: i32, + name: String, + } + + impl A { + pub fn new_a() -> A { + A { + number: 1, + name: String::from("A"), + } + } + + pub fn print_a(&self) { + println!("number: {}, name: {}", self.number, self.name); + } + } + + pub mod modB { + pub fn print_B() { + println!("B"); + } + + pub mod modC { + pub fn print_C() { + println!("C"); + super::print_B(); + } + } + } +} + +//use modA::A; +use modA::A as A1; +fn main() { + //let a = modA::A::new_a(); + //let a = A::new_a(); + let a = A1::new_a(); + a.print_a(); + + let number = a.number; + //let name = a.name; + + println!("+++++++++++++"); + modA::modB::modC::print_C(); + println!("Hello, world!"); +} diff --git a/learn_crate4/.gitignore b/learn_crate4/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_crate4/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_crate4/Cargo.lock b/learn_crate4/Cargo.lock new file mode 100644 index 00000000..85fb1935 --- /dev/null +++ b/learn_crate4/Cargo.lock @@ -0,0 +1,133 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "learn_crate4" +version = "0.1.0" +dependencies = [ + "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.2.65" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rust-crypto" +version = "0.2.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-serialize" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" +"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" +"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" +"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/learn_crate4/Cargo.toml b/learn_crate4/Cargo.toml new file mode 100644 index 00000000..8bc18516 --- /dev/null +++ b/learn_crate4/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "learn_crate4" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rust-crypto = "0.2" diff --git a/learn_crate4/src/main.rs b/learn_crate4/src/main.rs new file mode 100644 index 00000000..62866a6a --- /dev/null +++ b/learn_crate4/src/main.rs @@ -0,0 +1,13 @@ +extern crate crypto; + +use crypto::digest::Digest; +use crypto::sha3::Sha3; + +fn main() { + let mut hasher = Sha3::sha3_256(); + hasher.input_str("hello world"); + let result = hasher.result_str(); + println!("hash = {}", result); + + println!("Hello, world!"); +} diff --git a/learn_deref/.gitignore b/learn_deref/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_deref/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_deref/Cargo.lock b/learn_deref/Cargo.lock new file mode 100644 index 00000000..33ba094a --- /dev/null +++ b/learn_deref/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_deref" +version = "0.1.0" + diff --git a/learn_deref/Cargo.toml b/learn_deref/Cargo.toml new file mode 100644 index 00000000..e6844bd9 --- /dev/null +++ b/learn_deref/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_deref" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_deref/src/main.rs b/learn_deref/src/main.rs new file mode 100644 index 00000000..531b9528 --- /dev/null +++ b/learn_deref/src/main.rs @@ -0,0 +1,15 @@ +////实现Deref trait允许我们重载解引用运算符。 +//let a: A = A::new();//前提:A类型必须实现Deref trait +//let b = &a; +//let c = *b;//解引用 + +fn main() { + let x = 5; + let y = &x; + assert_eq!(5, x); + assert_eq!(5, *y); //解引用 + + let z = Box::new(x); + assert_eq!(5, *z); + println!("Hello, world!"); +} diff --git a/learn_deref1/.gitignore b/learn_deref1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_deref1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_deref1/Cargo.lock b/learn_deref1/Cargo.lock new file mode 100644 index 00000000..be265954 --- /dev/null +++ b/learn_deref1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_deref1" +version = "0.1.0" + diff --git a/learn_deref1/Cargo.toml b/learn_deref1/Cargo.toml new file mode 100644 index 00000000..263f635d --- /dev/null +++ b/learn_deref1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_deref1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_deref1/src/main.rs b/learn_deref1/src/main.rs new file mode 100644 index 00000000..1cb81ec0 --- /dev/null +++ b/learn_deref1/src/main.rs @@ -0,0 +1,36 @@ +use std::ops::Deref; +struct MyBox(T); + +impl MyBox { + fn new(x: T) -> MyBox { + MyBox(x) + } +} + +impl Deref for MyBox { + type Target = T; + fn deref(&self) -> &T { + &self.0 + } +} + +fn main() { + let x = 5; + let y = MyBox::new(x); + + assert_eq!(5, x); + assert_eq!(5, *y); + + let m = MyBox::new(String::from("Rust")); + hello(&m); //将MyBox变为&String,再将String的解引用,变为字符串slice。 &str + println!("Hello, world!"); +} + +fn hello(name: &str) { + println!("Hello, {}", name); +} + +//解引用多态与可变性交互: +//(1)当T:Deref时,从&T到&U +//(2)当T:DerefMut时,从&mut T 到&mut U +//(3)当T:Deref时,从&mut T到&U diff --git a/learn_drop/.gitignore b/learn_drop/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_drop/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_drop/Cargo.lock b/learn_drop/Cargo.lock new file mode 100644 index 00000000..fd274713 --- /dev/null +++ b/learn_drop/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_drop" +version = "0.1.0" + diff --git a/learn_drop/Cargo.toml b/learn_drop/Cargo.toml new file mode 100644 index 00000000..ec34b94f --- /dev/null +++ b/learn_drop/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_drop" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_drop/src/main.rs b/learn_drop/src/main.rs new file mode 100644 index 00000000..37716a52 --- /dev/null +++ b/learn_drop/src/main.rs @@ -0,0 +1,25 @@ +//1、Drop trait类似于其它语言中的析构函数,当值离开作用域的时候执行此函数的代码。 +// +struct Dog { + name: String, + //count: i32, +} + +impl Drop for Dog{ + fn drop(&mut self) { + println!("Dog {} leave", self.name); + //self.count -= 1; + } +} + +fn main() { + let a = Dog{name: String::from("wangcai")}; + { + let b = Dog{name: String::from("dahuang")}; + println!("0 +++++++++++++++++++"); + } + + println!("1 +++++++++++++++++++"); + + println!("Hello, world!"); +} diff --git a/learn_drop1/.gitignore b/learn_drop1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_drop1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_drop1/Cargo.lock b/learn_drop1/Cargo.lock new file mode 100644 index 00000000..9a2fa60e --- /dev/null +++ b/learn_drop1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_drop1" +version = "0.1.0" + diff --git a/learn_drop1/Cargo.toml b/learn_drop1/Cargo.toml new file mode 100644 index 00000000..ff80f461 --- /dev/null +++ b/learn_drop1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_drop1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_drop1/src/main.rs b/learn_drop1/src/main.rs new file mode 100644 index 00000000..bd6b0a68 --- /dev/null +++ b/learn_drop1/src/main.rs @@ -0,0 +1,21 @@ +struct Dog { + name: String, +} + +impl Drop for Dog { + fn drop(&mut self) { + println!("{} leave", self.name); + } +} + +//rust提供了std::mem::drop() +fn main() { + let a = Dog{name: String::from("wangcai")}; + let b = Dog{name: String::from("dahuang")}; + //b.drop(); + drop(b); + drop(a); + + println!("0 ++++++++++++++++++++++"); + println!("Hello, world!"); +} diff --git a/learn_enum/.gitignore b/learn_enum/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_enum/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_enum/Cargo.lock b/learn_enum/Cargo.lock new file mode 100644 index 00000000..d6cf8870 --- /dev/null +++ b/learn_enum/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_enum" +version = "0.1.0" + diff --git a/learn_enum/Cargo.toml b/learn_enum/Cargo.toml new file mode 100644 index 00000000..5b4c356c --- /dev/null +++ b/learn_enum/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_enum" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_enum/src/main.rs b/learn_enum/src/main.rs new file mode 100644 index 00000000..073d8e58 --- /dev/null +++ b/learn_enum/src/main.rs @@ -0,0 +1,84 @@ +//1、类似于c语言的方式定义 +enum IpAddrKind { + V4, + V6, +} + +struct IpAddr { + kind: IpAddrKind, + address: String, +} + +//2、rust语言提倡的方式定义 +enum IpAddr2 { + V4(String), + V6(String), +} + +//3、可以是不同类型 +enum IpAddr3 { + V4(u8, u8, u8, u8), + V6(String), +} + +//4、经典用法 +enum Message { + Quit, + Move{x: i32, y: i32}, + Write(String), + Change(i32, i32, i32), +} + +//等同于 +//struct QuitMessage; //类单元结构体 +//struct MoveMessage { +// x: i32, +// y: i32, +//} +//struct WriteMessage(String) +//struct Change(i32, i32, i32) + +//5、枚举类型的方法以及match +impl Message { + fn prin(&self) { + match *self { + Message::Quit => println!("Quit"), + Message::Move{x, y} => println!("Move x = {}, y = {}", x, y), + Message::Change(a, b, c) => println!("Change a = {}, b = {}, c = {}", a, b, c), + _ => println!("Write") + //Message::Write(&s) => println!("Write = {}", s) + } + } +} + +fn main() { + let i1 = IpAddr { + kind: IpAddrKind::V4, + address: String::from("127.0.0.1"), + }; + + let i2 = IpAddr { + kind: IpAddrKind::V6, + address: String::from("::1"), + }; + + let i1 = IpAddr2::V4(String::from("127.0.0.1")); + let i2 = IpAddr2::V6(String::from("::1")); + + let i1 = IpAddr3::V4(127, 0, 0, 1); + let i2 = IpAddr3::V6(String::from("::1")); + + let quit = Message::Quit; + quit.prin(); + + + let mo = Message::Move{x: 10, y: 20}; + mo.prin(); + + let wri = Message::Write(String::from("Hello")); + wri.prin(); + + let change = Message::Change(1, 2, 3); + change.prin(); + println!("Hello, world!"); +} diff --git a/learn_err1/.gitignore b/learn_err1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_err1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_err1/Cargo.lock b/learn_err1/Cargo.lock new file mode 100644 index 00000000..8c547e40 --- /dev/null +++ b/learn_err1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_err1" +version = "0.1.0" + diff --git a/learn_err1/Cargo.toml b/learn_err1/Cargo.toml new file mode 100644 index 00000000..f11ff09c --- /dev/null +++ b/learn_err1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_err1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_err1/src/main.rs b/learn_err1/src/main.rs new file mode 100644 index 00000000..02400719 --- /dev/null +++ b/learn_err1/src/main.rs @@ -0,0 +1,28 @@ +//1、rust语言将错误分为两个类别:可恢复错误和不可恢复错误 +//(1)可恢复错误通常代表向用户报告错误和重试操作是合理的情况,例如未找到文件。rust中使用Result来实现。 +//(2)不可恢复错误是bug的同义词,如尝试访问超过数组结尾的位置。rust中通过panic!来实现。 + +//2、panic! + +//3、使用BACKTRACE=1 + +//4、Result +//enum Result { +// Ok(T), +// Err(E), +//} + +//5、简写 +use std::fs::File; +fn main() { + //let f = File::open("hello.txt"); + //let r = match f { + // Ok(file) => file, + // Err(error) => panic!("error: {:?}", error), + //}; + + + //let f = File::open("hello.txt").unwrap(); + let f = File::open("hello.txt").expect("Failed to open hello.txt"); + //panic!("crash here"); +} diff --git a/learn_err2/.gitignore b/learn_err2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_err2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_err2/Cargo.lock b/learn_err2/Cargo.lock new file mode 100644 index 00000000..657b63c1 --- /dev/null +++ b/learn_err2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_err2" +version = "0.1.0" + diff --git a/learn_err2/Cargo.toml b/learn_err2/Cargo.toml new file mode 100644 index 00000000..e95bcb6e --- /dev/null +++ b/learn_err2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_err2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_err2/src/main.rs b/learn_err2/src/main.rs new file mode 100644 index 00000000..6b01726b --- /dev/null +++ b/learn_err2/src/main.rs @@ -0,0 +1,47 @@ +//1、当编写一个函数,但是该函数可能会失败,此时除了在函数中处理错误外,还可以将错误传给调用者,让调用者决定如何处理,这被称为传播错误。 +//2、传播错误的简写方式,提倡的方式 +//3、更进一步的简写 +//4、什么时候用panic!,什么时候用Result +//(1)示例、代码原型、测试用panic!\unwrap\expect +//(2)实际项目中应该用Result +//5、Option和Result + +use std::io; +use std::io::Read; +use std::fs::File; +fn main() { + println!("Hello, world!"); + let r = read_username_from_file(); + match r { + Ok(s) => println!("s = {}", s), + Err(e) => println!("err = {:?}", e), + } +} + +//fn read_username_from_file() -> Result { +// let f = File::open("hello.txt"); +// let mut f = match f { +// Ok(file) => file, +// Err(error) => return Err(error), +// }; +// +// let mut s = String::new(); +// match f.read_to_string(&mut s) { +// Ok(_) => Ok(s), +// Err(error) => Err(error), +// } +//} +// +//fn read_username_from_file() -> Result { +// let mut f = File::open("hello.txt")?; +// +// let mut s = String::new(); +// f.read_to_string(&mut s)?; +// Ok(s) +//} + +fn read_username_from_file() -> Result { + let mut s = String::new(); + File::open("hello.txt")?.read_to_string(&mut s)?; + Ok(s) +} diff --git a/learn_fn/.gitignore b/learn_fn/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_fn/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_fn/Cargo.lock b/learn_fn/Cargo.lock new file mode 100644 index 00000000..620ab4d0 --- /dev/null +++ b/learn_fn/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_fn" +version = "0.1.0" + diff --git a/learn_fn/Cargo.toml b/learn_fn/Cargo.toml new file mode 100644 index 00000000..4c4a67cb --- /dev/null +++ b/learn_fn/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_fn" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_fn/src/main.rs b/learn_fn/src/main.rs new file mode 100644 index 00000000..2c75f275 --- /dev/null +++ b/learn_fn/src/main.rs @@ -0,0 +1,49 @@ +fn other_fun() { + println!("This is a function"); +} + +fn other_fun1(a: i32, b: u32) { +//fn other_fun1(a, b) { //error + println!("a = {}, b = {}", a, b); +} + +fn other_fun2(a: i32, b: i32) -> i32 { + let result = a + b; + return result; +} + +fn other_fun3(a: i32, b: i32) -> i32 { + //let result = a + b; + //result + a + b +} + +fn main() { + other_fun(); + + let a: i32 = -1; + let b: u32 = 2; + other_fun1(a, b); + + let c: i32 = 9; + let r: i32 = other_fun2(a, c); + println!("r = {}", r); + + let r2: i32 = other_fun3(a, c); + println!("r2 = {}", r2); + + //语句是执行一些操作,但是不返回值的指令 + //let y = 1; //语句,不返回值 + //let x = (let y = 1); + + //表达式会计算一些值 + let y = { + let x = 1; + //x + 1; + x + 1 + }; + + println!("y = {}", y); + + println!("Hello, world!"); +} diff --git a/learn_fn2/.gitignore b/learn_fn2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_fn2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_fn2/Cargo.lock b/learn_fn2/Cargo.lock new file mode 100644 index 00000000..6f52f3e6 --- /dev/null +++ b/learn_fn2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_fn2" +version = "0.1.0" + diff --git a/learn_fn2/Cargo.toml b/learn_fn2/Cargo.toml new file mode 100644 index 00000000..8bfa56a0 --- /dev/null +++ b/learn_fn2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_fn2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_fn2/src/main.rs b/learn_fn2/src/main.rs new file mode 100644 index 00000000..9d16ab8f --- /dev/null +++ b/learn_fn2/src/main.rs @@ -0,0 +1,19 @@ +fn takes_ownership(some_string: String) -> String{ + println!("{}", some_string); + some_string +} + +fn makes_copy(i: i32) { + println!("i = {}", i); +} + +fn main() { + let s = String::from("hello"); + let s1 = takes_ownership(s); + println!("{}", s1); + + let x = 5; + makes_copy(x); + println!("{}", x); + println!("Hello, world!"); +} diff --git a/learn_hashmap/.gitignore b/learn_hashmap/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_hashmap/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_hashmap/Cargo.lock b/learn_hashmap/Cargo.lock new file mode 100644 index 00000000..216fc242 --- /dev/null +++ b/learn_hashmap/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_hashmap" +version = "0.1.0" + diff --git a/learn_hashmap/Cargo.toml b/learn_hashmap/Cargo.toml new file mode 100644 index 00000000..577162e3 --- /dev/null +++ b/learn_hashmap/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_hashmap" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_hashmap/src/main.rs b/learn_hashmap/src/main.rs new file mode 100644 index 00000000..d4f8f21c --- /dev/null +++ b/learn_hashmap/src/main.rs @@ -0,0 +1,62 @@ +//1、HashMap +//2、创建HashMap +//3、读取 +//4、遍历 +//5、更新 +use std::collections::HashMap; + +fn main() { + let mut scores: HashMap = HashMap::new(); + scores.insert(String::from("Blue"), 10); + scores.insert(String::from("Red"), 20); + + let keys = vec![String::from("Blue"), String::from("Red")]; + let values = vec![10, 20]; + let scores: HashMap<_, _> = keys.iter().zip(values.iter()).collect(); + + let k = String::from("Blue"); + if let Some(v) = scores.get(&k) { //get 返回的是一个Option + println!("v = {}", v); + } + + let k = String::from("Yellow"); + let v = scores.get(&k); + match v { + Some(value) => println!("v = {}", value), + None => println!("None"), + } + + println!("++++++++++++"); + //遍历:会以任意的顺序遍历出来 + for (key, value) in &scores { + println!("{}, {}", key, value); + } + println!("++++++++++++"); + + //直接插入 + let mut ss = HashMap::new(); + ss.insert(String::from("one"), 1); + ss.insert(String::from("two"), 2); + ss.insert(String::from("three"), 3); + ss.insert(String::from("one"), 3); + println!("{:?}", ss); + + //键不存在的时候才插入 + let mut ss1 = HashMap::new(); + ss1.insert(String::from("one"), 1); + ss1.insert(String::from("two"), 2); + ss1.insert(String::from("three"), 3); + ss1.entry(String::from("one")).or_insert(3); + println!("ss1 = {:?}", ss1); + + //根据旧值来更新一个值 + let text = "hello world wonderful world"; + let mut map = HashMap::new(); + for word in text.split_whitespace() { + let count = map.entry(word).or_insert(0); + *count += 1; + } + println!("map = {:?}", map); + + println!("Hello, world!"); +} diff --git a/learn_iter1/.gitignore b/learn_iter1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_iter1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_iter1/Cargo.lock b/learn_iter1/Cargo.lock new file mode 100644 index 00000000..22a30339 --- /dev/null +++ b/learn_iter1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_iter1" +version = "0.1.0" + diff --git a/learn_iter1/Cargo.toml b/learn_iter1/Cargo.toml new file mode 100644 index 00000000..5e1c01ef --- /dev/null +++ b/learn_iter1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_iter1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_iter1/src/main.rs b/learn_iter1/src/main.rs new file mode 100644 index 00000000..0058f40f --- /dev/null +++ b/learn_iter1/src/main.rs @@ -0,0 +1,62 @@ +//1、迭代器负责遍历序列中的每一项和决定序列何时结束的逻辑。 +//2、创建迭代器:迭代器是惰性的,意思就是在调用方法使用迭代器之前,不会有任何效果 +//3、每个迭代器都实现了iterator trait, iterator trait定义在标准库中: +//trait Iterator { +// type Item; +// fn next(mut self) -> Option; //type Item和Self::Item这种用法叫做定义trait的关联类型 +//} +////next是Iterator被要求实现的唯一的一个方法,next一次返回一个元素,当迭代器结束时候,返回None + +fn main() { + let v1 = vec![1, 2, 3]; + let mut v1_iter = v1.iter(); //到目前为止,不会对v1产生任何影响 + //for val in v1_iter { + // println!("val = {}", val); + //} + if let Some(v) = v1_iter.next() { + println!("v = {}", v);//1 + } + if let Some(v) = v1_iter.next() { + println!("v = {}", v);//2 + } + if let Some(v) = v1_iter.next() { + println!("v = {}", v);//3 + } + if let Some(v) = v1_iter.next() { + println!("v = {}", v); + } else { + println!("At end"); + } + + //-----迭代可变引用----- + let mut v2 = vec![1, 2, 3]; + let mut v2_iter = v2.iter_mut(); + if let Some(v) = v2_iter.next() { + *v = 3; + } + println!("v2 = {:?}", v2); + + //-----消费适配器------ + let v1 = vec![1, 2, 3]; + let v1_iter = v1.iter(); + let total: i32 = v1_iter.sum();//调用消费适配器sum来求和 + println!("total = {}", total); + + //-----迭代适配器------ + println!("++++++++++++"); + let v1 = vec![1, 2, 3]; + println!("v1 = {:?}", v1); + + let v2: Vec<_> = v1.iter().map(|x| x+1).collect(); + println!("v2 = {:?}", v2); + + //------------------------ + println!("++++++++++++"); + let v1 = vec![1, 12, 3, 45]; + println!("v1 = {:?}", v1); + + let v2: Vec<_> = v1.into_iter().filter(|x| *x > 5).collect(); + println!("v2 = {:?}", v2); + + println!("Hello, world!"); +} diff --git a/learn_iter2/.gitignore b/learn_iter2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_iter2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_iter2/Cargo.lock b/learn_iter2/Cargo.lock new file mode 100644 index 00000000..8307db48 --- /dev/null +++ b/learn_iter2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_iter2" +version = "0.1.0" + diff --git a/learn_iter2/Cargo.toml b/learn_iter2/Cargo.toml new file mode 100644 index 00000000..59d27d48 --- /dev/null +++ b/learn_iter2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_iter2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_iter2/src/main.rs b/learn_iter2/src/main.rs new file mode 100644 index 00000000..f9664377 --- /dev/null +++ b/learn_iter2/src/main.rs @@ -0,0 +1,35 @@ +struct Counter { + count: u32, +} + +impl Counter { + fn new() -> Counter { + Counter {count: 0} + } +} + +impl Iterator for Counter { + type Item = u32; + fn next(&mut self) -> Option { + self.count += 1; + if self.count < 6 { + Some(self.count) + } else { + None + } + } +} + +fn main() { + let mut counter = Counter::new(); + for i in (0..6) { + if let Some(v) = counter.next() { + println!("i = {}, v = {}", i, v); + } else { + println!("i = {}, at end", i); + break; + } + } + + println!("Hello, world!"); +} diff --git a/learn_life1/.gitignore b/learn_life1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_life1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_life1/Cargo.lock b/learn_life1/Cargo.lock new file mode 100644 index 00000000..112dc203 --- /dev/null +++ b/learn_life1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_life1" +version = "0.1.0" + diff --git a/learn_life1/Cargo.toml b/learn_life1/Cargo.toml new file mode 100644 index 00000000..14abcb06 --- /dev/null +++ b/learn_life1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_life1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_life1/bak b/learn_life1/bak new file mode 100644 index 00000000..d2f091df --- /dev/null +++ b/learn_life1/bak @@ -0,0 +1,26 @@ +//1、Rust中每一个引用都有其生命周期,也就是引用保持有效的作用域。大部分时候生命周期是隐含并可以推断的,正如大部分时候类型可以推断一样。 +// +//2、生命周期的主要目标是避免悬垂引用。 +// +//3、Rust编译器使用借用检查器来检查生命周期是否有效。 +fn main() { +// //错误例子1 +// let r; //---------------------------+------------'a +// { // + +// let x = 5; //-------+------'b | +// r = &x; // | | +// } //-------+ | +// println!("r = {}", r); // | +// // | +// println!("Hello, world!"); // | +//} //---------------------------+ + + let r; //---------------------------+------------'a + // + + let x = 5; //-------+------'b | + r = &x; // | | + // | | + println!("r = {}", r); // | | + // | | + println!("Hello, world!"); // | | +} //---------------------------+ diff --git a/learn_life1/bl b/learn_life1/bl new file mode 100644 index 00000000..078158f0 --- /dev/null +++ b/learn_life1/bl @@ -0,0 +1,14 @@ +//1、Rust中每一个引用都有其生命周期,也就是引用保持有效的作用域。大部分时候生命周期是隐含并可以推断的,正如大部分时候类型可以推断一样。 +// +//2、生命周期的主要目标是避免悬垂引用。 +// +//3、Rust编译器使用借用检查器来检查生命周期是否有效。 +fn main() { + let r; + { + let x = 5; + r = &x; + } + println!("r = {}", r); + println!("Hello, world!"); +} diff --git a/learn_life1/main.rs b/learn_life1/main.rs new file mode 100644 index 00000000..d2f091df --- /dev/null +++ b/learn_life1/main.rs @@ -0,0 +1,26 @@ +//1、Rust中每一个引用都有其生命周期,也就是引用保持有效的作用域。大部分时候生命周期是隐含并可以推断的,正如大部分时候类型可以推断一样。 +// +//2、生命周期的主要目标是避免悬垂引用。 +// +//3、Rust编译器使用借用检查器来检查生命周期是否有效。 +fn main() { +// //错误例子1 +// let r; //---------------------------+------------'a +// { // + +// let x = 5; //-------+------'b | +// r = &x; // | | +// } //-------+ | +// println!("r = {}", r); // | +// // | +// println!("Hello, world!"); // | +//} //---------------------------+ + + let r; //---------------------------+------------'a + // + + let x = 5; //-------+------'b | + r = &x; // | | + // | | + println!("r = {}", r); // | | + // | | + println!("Hello, world!"); // | | +} //---------------------------+ diff --git a/learn_life1/src/main.rs b/learn_life1/src/main.rs new file mode 100644 index 00000000..c3d7079f --- /dev/null +++ b/learn_life1/src/main.rs @@ -0,0 +1,26 @@ +//1、Rust中每一个引用都有其生命周期,也就是引用保持有效的作用域。大部分时候生命周期是隐含并可以推断的,正如大部分时候类型可以推断一样。 +// +//2、生命周期的主要目标是避免悬垂引用。 +// +//3、Rust编译器使用借用检查器来检查生命周期是否有效。 +fn main() { + ////错误例子1 + //let r; //---------------------------+------------'a + //{ // + + // let x = 5; //-------+------'b | + // r = &x; // | | + //} //-------+ | + //println!("r = {}", r); // | + // // | + //println!("Hello, world!"); // | + // //---------------------------+ + // + let r; //---------------------------+------------'a + // + + let x = 5; //-------+------'b | + r = &x; // | | + // | | + println!("r = {}", r); // | | + // | | + println!("Hello, world!"); // | | +} //---------------------------+ diff --git a/learn_life2/.gitignore b/learn_life2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_life2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_life2/Cargo.lock b/learn_life2/Cargo.lock new file mode 100644 index 00000000..0935ff82 --- /dev/null +++ b/learn_life2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_life2" +version = "0.1.0" + diff --git a/learn_life2/Cargo.toml b/learn_life2/Cargo.toml new file mode 100644 index 00000000..a9b25413 --- /dev/null +++ b/learn_life2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_life2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_life2/src/main.rs b/learn_life2/src/main.rs new file mode 100644 index 00000000..772d1ce6 --- /dev/null +++ b/learn_life2/src/main.rs @@ -0,0 +1,32 @@ +//函数中的生命周期 +//fn longest(x: &str, y: &str) -> &str { +//fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { +fn longest<'c>(x: &'c str, y: &'c str) -> &'c str { + if x.len() > y.len() { + x + } else { + y + } +} + +fn get_str<'a>(x: &'a str, y: &str) -> &'a str { + x +} + +//error +//fn a_str<'a>(x: &'a str, y: &'a str) -> &'a str { +// let r = String::from("abc"); +// r.as_str() +//} + +fn main() { + let s1 = String::from("abcde"); + let s2 = String::from("ab"); + let r = longest(s1.as_str(), s2.as_str()); + println!("r = {}", r); + + let ss = get_str(s1.as_str(), s2.as_str()); + //let ss2 = a_str(s1.as_str(), s2.as_str()); + + println!("Hello, world!"); +} diff --git a/learn_life3/.gitignore b/learn_life3/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_life3/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_life3/Cargo.lock b/learn_life3/Cargo.lock new file mode 100644 index 00000000..ca90c734 --- /dev/null +++ b/learn_life3/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_life3" +version = "0.1.0" + diff --git a/learn_life3/Cargo.toml b/learn_life3/Cargo.toml new file mode 100644 index 00000000..068868fd --- /dev/null +++ b/learn_life3/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_life3" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_life3/src/main.rs b/learn_life3/src/main.rs new file mode 100644 index 00000000..5bf2aef5 --- /dev/null +++ b/learn_life3/src/main.rs @@ -0,0 +1,32 @@ +//1、结构体中的生命周期 +#[derive(Debug)] +struct A<'a> { + name: &'a str, +} + +fn main() { + let n = String::from("hello"); + let a = A{name: &n}; + println!("a = {:#?}", a); + + println!("Hello, world!"); + let s = get_a_str(&n); + println!("s = {}", s); +} + +//2、生命周期省略 +fn get_a_str(s: &str) -> &str { + s +} +//(1)没有生命周期注解却能够编译,原因:早期的rust中必须显式的声明生命周期,后来rust团队将很明确的模式进行了注解的简化。 +//(2)遵守生命周期省略规则的情况下能明确变量的声明周期,则无需明确指定生命周期。函数或者方法的参数的生命周期称为输入生命周期,而返回值的生命周期称为输出生命周期。 +//(3)编译器采用三条规则判断引用何时不需要生命周期注解,当编译器检查完这三条规则后仍然不能计算出引用的生命周期,则会停止并生成错误。 +//(4)生命周期注解省略规则适用于fn定义以及impl块定义,如下: +// a、每个引用的参数都有它自己的生命周期参数。例如如下: +// 一个引用参数的函数,其中有一个生命周期: fn foo<'a>(x: &'a i32) +// 两个引用参数的函数,则有两个生命周期 :fn foo<'a, 'b>(x: &'a i32, y: &'b i32) +// 以此类推。 +// b、如果只有一个输入生命周期参数,那么它被赋予所有输出生命周期参数: +// fn foo(x: &i32) -> &i32 等价于 fn foo<'a>(x: &'a i32) -> &'a i32 +// c、如果方法有多个输入生命周期参数,不过其中之一因为方法的缘故为&self或者&mut self,那么self的生命周期被赋予所有输出生命周期参数。例子在下面来看。 +// fn function(&self, x: &str, y: &str, ....) -> &str diff --git a/learn_life4/.gitignore b/learn_life4/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_life4/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_life4/Cargo.lock b/learn_life4/Cargo.lock new file mode 100644 index 00000000..244d4117 --- /dev/null +++ b/learn_life4/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_life4" +version = "0.1.0" + diff --git a/learn_life4/Cargo.toml b/learn_life4/Cargo.toml new file mode 100644 index 00000000..84deff91 --- /dev/null +++ b/learn_life4/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_life4" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_life4/src/main.rs b/learn_life4/src/main.rs new file mode 100644 index 00000000..7f78ad74 --- /dev/null +++ b/learn_life4/src/main.rs @@ -0,0 +1,30 @@ +//方法中的生命周期 +struct StuA<'a> { + name: &'a str, +} + +impl<'b> StuA<'b> { + fn do_something(&self) -> i32 { + 3 + } + + fn do_something2(&self, s: &str) -> &str{ + //fn do_something2<'b>(&'b self, s: &str) -> &'b str{ + self.name + } + + fn do_something3<'a>(&self, s: &'a str) -> &'a str{ + s + } +} + +fn main() { + let s = String::from("hello"); + let a = StuA{name: &s}; + println!("{}", a.do_something()); + let s2 = String::from("hello"); + println!("{}", a.do_something2(&s2)); + + println!("{}", a.do_something3(&s2)); + println!("Hello, world!"); +} diff --git a/learn_life5/.gitignore b/learn_life5/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_life5/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_life5/Cargo.lock b/learn_life5/Cargo.lock new file mode 100644 index 00000000..ba8d1782 --- /dev/null +++ b/learn_life5/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_life5" +version = "0.1.0" + diff --git a/learn_life5/Cargo.toml b/learn_life5/Cargo.toml new file mode 100644 index 00000000..e7bd6a50 --- /dev/null +++ b/learn_life5/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_life5" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_life5/src/main.rs b/learn_life5/src/main.rs new file mode 100644 index 00000000..021017b9 --- /dev/null +++ b/learn_life5/src/main.rs @@ -0,0 +1,25 @@ +//1、静态生命周期 +//定义方式: 'static +//其生命周期存活于整个程序期间,所有的字符字面值都拥有static生命周期。 +//let s: &'static str = "hello"; +// + +use std::fmt::Display; + +fn function<'a, T: Display>(x: &'a str, y: &'a str, ann: T) -> &'a str { + println!("ann is {}", ann); + if x.len() < y.len() { + x + } else { + y + } +} + +fn main() { + let s1 = String::from("i am s1"); + let s2 = String::from("i am s2, hello"); + let ann = 129; + let r = function(s1.as_str(), s2.as_str(), ann); + println!("r = {}", r); + println!("Hello, world!"); +} diff --git a/learn_option/.gitignore b/learn_option/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_option/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_option/Cargo.lock b/learn_option/Cargo.lock new file mode 100644 index 00000000..419dc3c9 --- /dev/null +++ b/learn_option/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_option" +version = "0.1.0" + diff --git a/learn_option/Cargo.toml b/learn_option/Cargo.toml new file mode 100644 index 00000000..723b064d --- /dev/null +++ b/learn_option/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_option" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_option/src/main.rs b/learn_option/src/main.rs new file mode 100644 index 00000000..5e85017f --- /dev/null +++ b/learn_option/src/main.rs @@ -0,0 +1,49 @@ +//1、Option是标准库定义的一个枚举,形式: +//enum Option { +// Some(T), +// None, +//} +// +//2、使用方式 +fn main() { + let some_number = Some(5); + let some_string = Some(String::from("a string")); + let absent_number: Option = None; + + let x: i32 = 5; + let y: Option = Some(5); + let mut temp = 0; + match y { + Some(i) => { temp = i; } + None => {println!("do nothing");} + } + + let sum = x + temp; + println!("sum = {}", sum); + + //let result = plus_one(y); + //match result { + // Some(i) => println!("result = {}", i), + // None => println!("nothing"), + //}; + + if let Some(value) = plus_one(y) { + println!("value = {}", value); + } + + + if let Some(value) = plus_one(y) { + println!("value = {}", value); + } else { + println!("do nothing"); + } + + println!("Hello, world!"); +} + +fn plus_one(x: Option) -> Option { + match x { + None => None, + Some(x) => Some(x+1), + } +} diff --git a/learn_own/.gitignore b/learn_own/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_own/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_own/Cargo.lock b/learn_own/Cargo.lock new file mode 100644 index 00000000..de4d89fb --- /dev/null +++ b/learn_own/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_own" +version = "0.1.0" + diff --git a/learn_own/Cargo.toml b/learn_own/Cargo.toml new file mode 100644 index 00000000..1f7642ad --- /dev/null +++ b/learn_own/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_own" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_own/src/main.rs b/learn_own/src/main.rs new file mode 100644 index 00000000..23c89977 --- /dev/null +++ b/learn_own/src/main.rs @@ -0,0 +1,54 @@ +//1 rust通过所有权机制来管理内存,编译器在编译就会根据所有权规则对内存的使用进行检查 +// +//2 堆和栈 +//编译的时候数据的类型大小是固定的,就是分配在栈上的 +//编译的时候数据类型大小不固定,就是分配堆上的 +// +//3 作用域:{} +// +//4 String内存回收 +//5 移动 +//6 clone +//7 栈上数据拷贝 +//8 函数和作用域 +fn main() { + let x: i32 = 1; + + { + let y: i32 = 1; + println!("x = {}", x); + println!("y = {}", y); + } + + { + let s1 = String::from("hello"); + //s1.push_str(" world"); + println!("s1 = {}", s1); //String类型离开作用域的时候会调用drop方法 + + let s2 = s1; + println!("s2= {}", s2); + //println!("s1= {}", s1); //move to s2, s1 invalid + // + + //clone + let s3 = s2.clone(); + println!("s3= {}", s3); + println!("s2= {}", s2); + } + + //copy trait + let a = 1; + let b = a; + println!("a = {}, b = {}", a, b); + //常用的具有copy trait有: + //所有的整型 + //浮点型 + //布尔值 + //字符类型 char + //元组 + + + + println!("Hello, world!"); + +} diff --git a/learn_rc1/.gitignore b/learn_rc1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_rc1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_rc1/Cargo.lock b/learn_rc1/Cargo.lock new file mode 100644 index 00000000..ec3bfe9d --- /dev/null +++ b/learn_rc1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_rc1" +version = "0.1.0" + diff --git a/learn_rc1/Cargo.toml b/learn_rc1/Cargo.toml new file mode 100644 index 00000000..5b516c47 --- /dev/null +++ b/learn_rc1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_rc1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_rc1/src/main.rs b/learn_rc1/src/main.rs new file mode 100644 index 00000000..00639344 --- /dev/null +++ b/learn_rc1/src/main.rs @@ -0,0 +1,27 @@ +//enum List { +// Cons(i32, Box), +// Nil, +//} +// +//use crate::List::{Cons, Nil}; + +enum List { + Cons(i32, Rc), + Nil, +} + +use crate::List::{Cons, Nil}; +use std::rc::Rc; + +fn main() { + //let a = Cons(5, Box::new(Cons(10, Box::new(Nil)))); + let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil))))); + + //let b = Cons(3, Box::new(a)); + //let b = Cons(3, Rc::clone(&a)); + let b = Cons(3, a.clone()); + + //let c = Cons(4, Box::new(a)); + let c = Cons(4, Rc::clone(&a)); + println!("Hello, world!"); +} diff --git a/learn_rc2/.gitignore b/learn_rc2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_rc2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_rc2/Cargo.lock b/learn_rc2/Cargo.lock new file mode 100644 index 00000000..f3270081 --- /dev/null +++ b/learn_rc2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_rc2" +version = "0.1.0" + diff --git a/learn_rc2/Cargo.toml b/learn_rc2/Cargo.toml new file mode 100644 index 00000000..97417c9d --- /dev/null +++ b/learn_rc2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_rc2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_rc2/src/main.rs b/learn_rc2/src/main.rs new file mode 100644 index 00000000..67f30855 --- /dev/null +++ b/learn_rc2/src/main.rs @@ -0,0 +1,24 @@ +//通过Rc允许程序的多个部分之间只读的共享数据,因为相同位置的多个可变引用可能会造成数据竞争和不一致。 +enum List { + Cons(i32, Rc), + Nil, +} + +use crate::List::{Cons, Nil}; +use std::rc::Rc; + +fn main() { + let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil))))); + println!("count after creating a = {}", Rc::strong_count(&a)); + + let b = Cons(3, Rc::clone(&a)); + println!("count after bind to b, a count = {}", Rc::strong_count(&a)); + + { + let c = Cons(4, Rc::clone(&a)); + println!("count after bind to c, a count = {}", Rc::strong_count(&a)); + } + + println!("count at end, a = {}", Rc::strong_count(&a)); + println!("Hello, world!"); +} diff --git a/learn_ref/.gitignore b/learn_ref/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_ref/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_ref/Cargo.lock b/learn_ref/Cargo.lock new file mode 100644 index 00000000..d8621ff5 --- /dev/null +++ b/learn_ref/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_ref" +version = "0.1.0" + diff --git a/learn_ref/Cargo.toml b/learn_ref/Cargo.toml new file mode 100644 index 00000000..8fac78b8 --- /dev/null +++ b/learn_ref/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_ref" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_ref/src/main.rs b/learn_ref/src/main.rs new file mode 100644 index 00000000..128520fc --- /dev/null +++ b/learn_ref/src/main.rs @@ -0,0 +1,52 @@ +//fn main() { +// let s1 = gives_ownership(); +// println!("s1 = {}", s1); +// +// let mut s2 = String::from("hello"); +// let s3 = takes_and_gives_back(s2); +// s2 = takes_and_gives_back(s3); +// println!("s2 = {}", s2); +// +// println!("Hello, world!"); +//} +// +//fn gives_ownership() -> String { +// let s = String::from("hello"); +// s +//} +// +//fn takes_and_gives_back(s: String) -> String { +// s +//} +//引用: 用法&, +//让我们创建一个指向值的应用,但是并不拥有它,因为不拥有这个值,所以,当引用离开其值指向的作用域后也不会被丢弃 +//借用:&mut +fn calcute_length(s: &String) ->usize { + s.len() +} + +fn modify_s(s: &mut String) { + s.push_str(", world"); +} + +fn main() { + let mut s1 = String::from("hello"); + + //let s = &s1; + //let len = calcute_length(s); + //println!("len = {}", len); + + //let ms = &mut s1; + //modify_s(ms); + + //println!("s1 = {}", s1); + //println!("s = {}", s); + //println!("ms = {}", ms); + + let r1 = &s1; + let r2 = &s1; + println!("{}, {}", r1, r2); + + let r3 = &mut s1; + r3.push_str(", world"); +} diff --git a/learn_ref2/.gitignore b/learn_ref2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_ref2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_ref2/Cargo.lock b/learn_ref2/Cargo.lock new file mode 100644 index 00000000..d49e7234 --- /dev/null +++ b/learn_ref2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_ref2" +version = "0.1.0" + diff --git a/learn_ref2/Cargo.toml b/learn_ref2/Cargo.toml new file mode 100644 index 00000000..6d015471 --- /dev/null +++ b/learn_ref2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_ref2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_ref2/src/main.rs b/learn_ref2/src/main.rs new file mode 100644 index 00000000..25bfb175 --- /dev/null +++ b/learn_ref2/src/main.rs @@ -0,0 +1,11 @@ +//1、在任意给定时间,有了可变引用之后不能再有不可变引用 +//2、引用必须有效 +fn main() { + let ref_s = dangle(); + println!("Hello, world!"); +} + +fn dangle() -> &String { + let s = String::from("hello"); + &s +} diff --git a/learn_refcell/.gitignore b/learn_refcell/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_refcell/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_refcell/Cargo.lock b/learn_refcell/Cargo.lock new file mode 100644 index 00000000..228a5d5f --- /dev/null +++ b/learn_refcell/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_refcell" +version = "0.1.0" + diff --git a/learn_refcell/Cargo.toml b/learn_refcell/Cargo.toml new file mode 100644 index 00000000..8384aaed --- /dev/null +++ b/learn_refcell/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_refcell" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_refcell/src/main.rs b/learn_refcell/src/main.rs new file mode 100644 index 00000000..fd6a9e0c --- /dev/null +++ b/learn_refcell/src/main.rs @@ -0,0 +1,37 @@ +//1、内部可变性:允许在使用不可变引用时改变数据。 +// +//2、通过RefCell在运行时检查借用规则(通常情况下,是在编译时检查借用规则),RefCell代表其数据的唯一所有权。 +//类似于Rc,RefCell只能用于单线程场景。 +// +//3、选择Box、Rc或RefCell的理由: +//Rc 允许相同数据有多个所有者;Box 和 RefCell 有单一所有者。 +//Box 允许在编译时执行不可变或可变借用检查;Rc仅允许在编译时执行不可变借用检查;RefCell 允许在运行时执行不可变或可变借用检查。 +//因为 RefCell 允许在运行时执行可变借用检查,所以我们可以在即便 RefCell 自身是不可变的情况下修改其内部的值。 +#[derive(Debug)] +enum List { + Cons(Rc>, Rc), + Nil, +} + +use crate::List::{Cons, Nil}; +use std::rc::Rc; +use std::cell::RefCell; + +fn main() { + let value = Rc::new(RefCell::new(5)); + + let a = Rc::new(Cons(Rc::clone(&value), Rc::new(Nil))); + let b = Cons(Rc::new(RefCell::new(6)), Rc::clone(&a)); + let c = Cons(Rc::new(RefCell::new(7)), Rc::clone(&a)); + println!("a before: {:?}", a); + println!("b before: {:?}", b); + println!("c before: {:?}", c); + + println!("+++++++++++++++++++"); + *value.borrow_mut() += 10; + println!("a after: {:?}", a); + println!("b after: {:?}", b); + println!("c after: {:?}", c); + + println!("Hello, world!"); +} diff --git a/learn_slice/.gitignore b/learn_slice/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_slice/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_slice/Cargo.lock b/learn_slice/Cargo.lock new file mode 100644 index 00000000..643cffdf --- /dev/null +++ b/learn_slice/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_slice" +version = "0.1.0" + diff --git a/learn_slice/Cargo.toml b/learn_slice/Cargo.toml new file mode 100644 index 00000000..a774520e --- /dev/null +++ b/learn_slice/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_slice" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_slice/src/main.rs b/learn_slice/src/main.rs new file mode 100644 index 00000000..60252110 --- /dev/null +++ b/learn_slice/src/main.rs @@ -0,0 +1,31 @@ +//1、字符串slice是String中一部分值的引用 +//2、字面值就是slice +//3、其它类型slice +fn main() { + let s = String::from("hello world"); + + let h = &s[0..5]; + let h = &s[0..=4]; + let h = &s[..=4]; + let h = &s[..5]; + println!("h = {}", h); + + let w = &s[6..11]; + let w = &s[6..=10]; + let w = &s[6..]; + let w = &s[..]; + println!("w = {}", w); + + //let ss = String::from("你好"); + //let w1 = &ss[0..1]; + + let s3 = "hh"; //&str + + + let a = [1, 2, 3, 4]; + let sss = &a[1..3]; + println!("sss = {}", sss[0]); + println!("sss = {}", sss[1]); + println!("len = {}", sss.len()); + println!("Hello, world!"); +} diff --git a/learn_string/.gitignore b/learn_string/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_string/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_string/Cargo.lock b/learn_string/Cargo.lock new file mode 100644 index 00000000..5161dded --- /dev/null +++ b/learn_string/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_string" +version = "0.1.0" + diff --git a/learn_string/Cargo.toml b/learn_string/Cargo.toml new file mode 100644 index 00000000..f4c71561 --- /dev/null +++ b/learn_string/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_string" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_string/src/main.rs b/learn_string/src/main.rs new file mode 100644 index 00000000..7c1d37b2 --- /dev/null +++ b/learn_string/src/main.rs @@ -0,0 +1,82 @@ +//1、创建一个空String +//2、通过字面值创建一个String +//2.1、使用String::from() +//2.2、使用str的方式 +//3、更新String +//3.1、push_str +//3.2、push +//3.3、使用“+”合并字符串 +//3.4、使用format! +//4、String 索引 +//5、str 索引 +//6、遍历 +//6.1、chars +//6.2、bytes +fn main() { + let mut s0 = String::new(); + s0.push_str("hello"); + println!("s0 = {}", s0); + + let s1 = String::from("init some thing"); + println!("{}", s1); + + let s1 = "init some thing".to_string(); + println!("{}", s1); + + let mut s2 = String::from("hello"); + s2.push_str(", world"); + let ss = " !".to_string(); + s2.push_str(&ss); + println!("{}", s2); + println!("ss = {}", ss); + + let mut s2 = String::from("tea"); + s2.push('m'); + //s2.push('mx'); //error + //s2.push("x"); //error + println!("{}", s2); + + let s1 = "hello".to_string(); + let s2 = String::from(", world"); + let s3 = s1 + &s2; + println!("s3 = {}", s3); + //println!("s1 = {}", s1); + println!("s2 = {}", s2); + + let s341 = String::from("tic"); + let s342 = String::from("tac"); + let s343 = String::from("toe"); + let s344 = format!("{}-{}-{}", s341, s342, s343); //format!和println!类似 + println!("s344 = {}", s344); + println!("s341 = {}", s341); + println!("s342 = {}", s342); + println!("s343 = {}", s343); + + let s4 = String::from("hello"); + //let s41 = s4[0]; + println!("s4.len = {}", s4.len()); + + let s4 = String::from("你好"); + println!("s4.len = {}", s4.len()); + //let s41 = s4[0]; + + let hello = "你好"; + let h5 = &hello[0..3]; + println!("h5 = {}", h5); + + //let h6 = &hello[0..2]; + //println!("h6 = {}", h6); + + //chars + for c in s4.chars() { + println!("c = {}", c); + } + + println!("+++++++++++++++"); + //bytes + for b in s4.bytes() { + println!("b = {}", b); + } + println!("+++++++++++++++"); + println!("Hello, world!"); +} diff --git a/learn_stru/.gitignore b/learn_stru/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_stru/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_stru/Cargo.lock b/learn_stru/Cargo.lock new file mode 100644 index 00000000..a75b73cc --- /dev/null +++ b/learn_stru/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_stru" +version = "0.1.0" + diff --git a/learn_stru/Cargo.toml b/learn_stru/Cargo.toml new file mode 100644 index 00000000..1ca75b1e --- /dev/null +++ b/learn_stru/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_stru" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_stru/src/main.rs b/learn_stru/src/main.rs new file mode 100644 index 00000000..ee4a40e6 --- /dev/null +++ b/learn_stru/src/main.rs @@ -0,0 +1,74 @@ +fn main() { + //1、定义结构体 + #[derive(Debug)] + struct User { + name: String, + count:String, + nonce: u64, + active: bool, + } + + //2、创建结构体实例 + let xiaoming = User { + name: String::from("xiaoming"), + count: String::from("80001000"), + nonce: 10000, + active:true, + }; + println!("xiaoming = {:?}", xiaoming); + println!("xiaoming = {:#?}", xiaoming); + + //3、修改结构体字段 + let mut xiaohuang = User { + name: String::from("xiaohuang"), + count: String::from("80001000"), + nonce: 10000, + active:true, + }; + + xiaohuang.nonce = 20000; + + //4、参数名字和字段名字同名的简写方法 + let name = String::from("xiaoxiao"); + let count = String::from("89077777"); + let nonce = 200000; + let active = false; + + //let user1 = User { + // name: name, + // count: count, + // nonce: nonce, + // active: active, + //}; + + let user1 = User { + name, + count, + nonce, + active, + }; + + //5、从其它结构体创建实例 + let user2 = User { + name: String::from("user2"), + ..user1 + }; + println!("name = {}", user2.name); + println!("nonce = {}", user2.nonce); + + //6、元组结构体 + //(1)字段没有名字 + //(2)圆括号 + struct Point(i32, i32); + + let a = Point(10, 20); + let b = Point(30, 11); + + println!("a.x = {}, a.y = {}", a.0, a.1); + + //7、没有任何字段的类单元结构体 + struct A{}; + + //8、打印结构体 + println!("Hello, world!"); +} diff --git a/learn_stu2/.gitignore b/learn_stu2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_stu2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_stu2/Cargo.lock b/learn_stu2/Cargo.lock new file mode 100644 index 00000000..9d5699e1 --- /dev/null +++ b/learn_stu2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_stu2" +version = "0.1.0" + diff --git a/learn_stu2/Cargo.toml b/learn_stu2/Cargo.toml new file mode 100644 index 00000000..3275a0b3 --- /dev/null +++ b/learn_stu2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_stu2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_stu2/src/main.rs b/learn_stu2/src/main.rs new file mode 100644 index 00000000..f95581e4 --- /dev/null +++ b/learn_stu2/src/main.rs @@ -0,0 +1,47 @@ +#[derive(Debug)] +struct Dog { + name: String, + weight: f32, + height: f32, +} + +impl Dog { + fn get_name(&self) -> &str { + &(self.name[..]) + } + + fn get_weight(&self) -> f32 { + self.weight + } + + //fn get_height(&self) -> f32 { + // self.height + //} + + fn show() { + println!("oh oh oh"); + } +} + +impl Dog{ + fn get_height(&self) -> f32 { + self.height + } +} + +fn main() { + let dog = Dog { + name: String::from("wangcai"), + weight: 100.0, + height: 70.5, + }; + + println!("dog = {:#?}", dog); + println!("name = {}", dog.get_name()); + println!("weight = {}", dog.get_weight()); + println!("height = {}", dog.get_height()); + + Dog::show(); + + println!("Hello, world!"); +} diff --git a/learn_test/.gitignore b/learn_test/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_test/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_test/Cargo.toml b/learn_test/Cargo.toml new file mode 100644 index 00000000..4d06bdec --- /dev/null +++ b/learn_test/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_test" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_test/mylib/Cargo.lock b/learn_test/mylib/Cargo.lock new file mode 100644 index 00000000..fb971d6f --- /dev/null +++ b/learn_test/mylib/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "mylib" +version = "0.1.0" + diff --git a/learn_test/mylib/Cargo.toml b/learn_test/mylib/Cargo.toml new file mode 100644 index 00000000..2e9d8c26 --- /dev/null +++ b/learn_test/mylib/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "mylib" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_test/mylib/src/animal.rs b/learn_test/mylib/src/animal.rs new file mode 100644 index 00000000..5b25d801 --- /dev/null +++ b/learn_test/mylib/src/animal.rs @@ -0,0 +1,19 @@ +pub mod dog { + pub fn hello() { + println!("wangwang"); + } + + pub fn is_dog() -> bool { + true + } +} + +pub mod cat { + pub fn hello() { + println!("miaomiao"); + } + + pub fn is_cat() -> bool { + true + } +} diff --git a/learn_test/mylib/src/lib.rs b/learn_test/mylib/src/lib.rs new file mode 100644 index 00000000..68407a23 --- /dev/null +++ b/learn_test/mylib/src/lib.rs @@ -0,0 +1,25 @@ +pub mod animal; + +#[cfg(test)] +mod tests { + //use animal::cat; + //use animal::dog; + use crate::animal::*; + + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } + + #[test] + fn use_cat() { + //cat::hello(); + assert_eq!(true, cat::is_cat()); + } + + #[test] + fn use_dog() { + //assert_eq!(true, animail::dog::is_dog()); + assert_eq!(true, dog::is_dog()); + } +} diff --git a/learn_test/mylib/target/.rustc_info.json b/learn_test/mylib/target/.rustc_info.json new file mode 100644 index 00000000..8667aaae --- /dev/null +++ b/learn_test/mylib/target/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":17989264669760749350,"outputs":{"1138116330425514636":["___\n",""],"4476964694761187371":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/andy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\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_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"2196823701345282402":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/andy/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\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_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"1164083562126845933":["rustc 1.38.0 (625451e37 2019-09-23)\nbinary: rustc\ncommit-hash: 625451e376bb2e5283fc4741caa0a3e8a2ca4d54\ncommit-date: 2019-09-23\nhost: x86_64-unknown-linux-gnu\nrelease: 1.38.0\nLLVM version: 9.0\n",""]},"successes":{}} \ No newline at end of file diff --git a/learn_test/mylib/target/debug/.cargo-lock b/learn_test/mylib/target/debug/.cargo-lock new file mode 100644 index 00000000..e69de29b diff --git a/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/dep-lib-mylib-76a11366c8786358 b/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/dep-lib-mylib-76a11366c8786358 new file mode 100644 index 00000000..4c3a7ac3 Binary files /dev/null and b/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/dep-lib-mylib-76a11366c8786358 differ diff --git a/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/invoked.timestamp b/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/invoked.timestamp new file mode 100644 index 00000000..e00328da --- /dev/null +++ b/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358 b/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358 new file mode 100644 index 00000000..85c87add --- /dev/null +++ b/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358 @@ -0,0 +1 @@ +b9bb53fc26387bf4 \ No newline at end of file diff --git a/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358.json b/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358.json new file mode 100644 index 00000000..cfe0fe8e --- /dev/null +++ b/learn_test/mylib/target/debug/.fingerprint/mylib-76a11366c8786358/lib-mylib-76a11366c8786358.json @@ -0,0 +1 @@ +{"rustc":10683586082858123265,"features":"[]","target":9023204661465037696,"profile":14996655781355331481,"path":10872709659218687626,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/mylib-76a11366c8786358/dep-lib-mylib-76a11366c8786358"}}],"rustflags":[],"metadata":15972075885573944569} \ No newline at end of file diff --git a/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/dep-test-lib-mylib-8daa0161999f343d b/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/dep-test-lib-mylib-8daa0161999f343d new file mode 100644 index 00000000..4c3a7ac3 Binary files /dev/null and b/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/dep-test-lib-mylib-8daa0161999f343d differ diff --git a/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/invoked.timestamp b/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/invoked.timestamp new file mode 100644 index 00000000..e00328da --- /dev/null +++ b/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d b/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d new file mode 100644 index 00000000..77451b46 --- /dev/null +++ b/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d @@ -0,0 +1 @@ +9e6f6e09989d6992 \ No newline at end of file diff --git a/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d.json b/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d.json new file mode 100644 index 00000000..27a99dba --- /dev/null +++ b/learn_test/mylib/target/debug/.fingerprint/mylib-8daa0161999f343d/test-lib-mylib-8daa0161999f343d.json @@ -0,0 +1 @@ +{"rustc":10683586082858123265,"features":"[]","target":9023204661465037696,"profile":8248545651247322450,"path":10872709659218687626,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/mylib-8daa0161999f343d/dep-test-lib-mylib-8daa0161999f343d"}}],"rustflags":[],"metadata":15972075885573944569} \ No newline at end of file diff --git a/learn_test/mylib/target/debug/deps/libmylib-76a11366c8786358.rlib b/learn_test/mylib/target/debug/deps/libmylib-76a11366c8786358.rlib new file mode 100644 index 00000000..a706f1df Binary files /dev/null and b/learn_test/mylib/target/debug/deps/libmylib-76a11366c8786358.rlib differ diff --git a/learn_test/mylib/target/debug/deps/libmylib-76a11366c8786358.rmeta b/learn_test/mylib/target/debug/deps/libmylib-76a11366c8786358.rmeta new file mode 100644 index 00000000..0e50aeaa Binary files /dev/null and b/learn_test/mylib/target/debug/deps/libmylib-76a11366c8786358.rmeta differ diff --git a/learn_test/mylib/target/debug/deps/mylib-76a11366c8786358.d b/learn_test/mylib/target/debug/deps/mylib-76a11366c8786358.d new file mode 100644 index 00000000..fdcfab8a --- /dev/null +++ b/learn_test/mylib/target/debug/deps/mylib-76a11366c8786358.d @@ -0,0 +1,8 @@ +/home/andy/source/rust/learn_rust/learn_test/mylib/target/debug/deps/mylib-76a11366c8786358.rmeta: src/lib.rs src/animal.rs + +/home/andy/source/rust/learn_rust/learn_test/mylib/target/debug/deps/libmylib-76a11366c8786358.rlib: src/lib.rs src/animal.rs + +/home/andy/source/rust/learn_rust/learn_test/mylib/target/debug/deps/mylib-76a11366c8786358.d: src/lib.rs src/animal.rs + +src/lib.rs: +src/animal.rs: diff --git a/learn_test/mylib/target/debug/deps/mylib-8daa0161999f343d b/learn_test/mylib/target/debug/deps/mylib-8daa0161999f343d new file mode 100755 index 00000000..2badd83f Binary files /dev/null and b/learn_test/mylib/target/debug/deps/mylib-8daa0161999f343d differ diff --git a/learn_test/mylib/target/debug/deps/mylib-8daa0161999f343d.d b/learn_test/mylib/target/debug/deps/mylib-8daa0161999f343d.d new file mode 100644 index 00000000..ad67e92f --- /dev/null +++ b/learn_test/mylib/target/debug/deps/mylib-8daa0161999f343d.d @@ -0,0 +1,6 @@ +/home/andy/source/rust/learn_rust/learn_test/mylib/target/debug/deps/mylib-8daa0161999f343d: src/lib.rs src/animal.rs + +/home/andy/source/rust/learn_rust/learn_test/mylib/target/debug/deps/mylib-8daa0161999f343d.d: src/lib.rs src/animal.rs + +src/lib.rs: +src/animal.rs: diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/2jvsnlbukpvh0p1u.bc.z b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/2jvsnlbukpvh0p1u.bc.z new file mode 100644 index 00000000..eea169a7 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/2jvsnlbukpvh0p1u.bc.z differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/2jvsnlbukpvh0p1u.o b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/2jvsnlbukpvh0p1u.o new file mode 100644 index 00000000..89feb0da Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/2jvsnlbukpvh0p1u.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/5da86x6qwjz6y50x.bc.z b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/5da86x6qwjz6y50x.bc.z new file mode 100644 index 00000000..2b534bff Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/5da86x6qwjz6y50x.bc.z differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/5da86x6qwjz6y50x.o b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/5da86x6qwjz6y50x.o new file mode 100644 index 00000000..f6346508 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/5da86x6qwjz6y50x.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/dep-graph.bin b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/dep-graph.bin new file mode 100644 index 00000000..dc0fda3c Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/dep-graph.bin differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/query-cache.bin b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/query-cache.bin new file mode 100644 index 00000000..a13d9dc1 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/query-cache.bin differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/work-products.bin b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/work-products.bin new file mode 100644 index 00000000..cf1af350 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/work-products.bin differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/wqz05vvmc3bfj7t.bc.z b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/wqz05vvmc3bfj7t.bc.z new file mode 100644 index 00000000..12fa47a0 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/wqz05vvmc3bfj7t.bc.z differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/wqz05vvmc3bfj7t.o b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/wqz05vvmc3bfj7t.o new file mode 100644 index 00000000..56430d83 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo-1nbdf5b1jcny1/wqz05vvmc3bfj7t.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo.lock b/learn_test/mylib/target/debug/incremental/mylib-2kpn2mvj4vltt/s-fi51a8hiao-1k5onlo.lock new file mode 100755 index 00000000..e69de29b diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2ke67ovyhs1f9tft.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2ke67ovyhs1f9tft.o new file mode 100644 index 00000000..2b5bda1c Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2ke67ovyhs1f9tft.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2pk8w25w94qu8196.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2pk8w25w94qu8196.o new file mode 100644 index 00000000..d330d668 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2pk8w25w94qu8196.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2y6udc3ryz6oktb9.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2y6udc3ryz6oktb9.o new file mode 100644 index 00000000..0346251d Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/2y6udc3ryz6oktb9.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/36an4yzzbds4xc28.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/36an4yzzbds4xc28.o new file mode 100644 index 00000000..85ad7af6 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/36an4yzzbds4xc28.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/3jy6a5kzfyqwn34x.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/3jy6a5kzfyqwn34x.o new file mode 100644 index 00000000..12731cd8 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/3jy6a5kzfyqwn34x.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/3pnyywknnlk3lqpa.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/3pnyywknnlk3lqpa.o new file mode 100644 index 00000000..75334324 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/3pnyywknnlk3lqpa.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4bym1ojtwdl54cuk.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4bym1ojtwdl54cuk.o new file mode 100644 index 00000000..d2eb28d2 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4bym1ojtwdl54cuk.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4k8iql66u94u44l8.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4k8iql66u94u44l8.o new file mode 100644 index 00000000..cfa893bf Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4k8iql66u94u44l8.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4l71ayu7r3iacfmc.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4l71ayu7r3iacfmc.o new file mode 100644 index 00000000..f9a50b9d Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4l71ayu7r3iacfmc.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4s5f676lv7394sdw.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4s5f676lv7394sdw.o new file mode 100644 index 00000000..339c6b40 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/4s5f676lv7394sdw.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/8siw2w8d78ltrgb.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/8siw2w8d78ltrgb.o new file mode 100644 index 00000000..72c42b4b Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/8siw2w8d78ltrgb.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/dep-graph.bin b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/dep-graph.bin new file mode 100644 index 00000000..1be8136c Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/dep-graph.bin differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/query-cache.bin b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/query-cache.bin new file mode 100644 index 00000000..aadef021 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/query-cache.bin differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/vaepn1j3hu7h61y.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/vaepn1j3hu7h61y.o new file mode 100644 index 00000000..cea7bb7c Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/vaepn1j3hu7h61y.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/wkhmx50wcbitygx.o b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/wkhmx50wcbitygx.o new file mode 100644 index 00000000..272cafe3 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/wkhmx50wcbitygx.o differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/work-products.bin b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/work-products.bin new file mode 100644 index 00000000..88479c94 Binary files /dev/null and b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o-3isxhcydnkkj/work-products.bin differ diff --git a/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o.lock b/learn_test/mylib/target/debug/incremental/mylib-g61j4px4vam1/s-fi51a8l8dl-1ew131o.lock new file mode 100755 index 00000000..e69de29b diff --git a/learn_test/mylib/target/debug/mylib-8daa0161999f343d b/learn_test/mylib/target/debug/mylib-8daa0161999f343d new file mode 100755 index 00000000..2badd83f Binary files /dev/null and b/learn_test/mylib/target/debug/mylib-8daa0161999f343d differ diff --git a/learn_test/mylib/target/debug/mylib-8daa0161999f343d.d b/learn_test/mylib/target/debug/mylib-8daa0161999f343d.d new file mode 100644 index 00000000..5f522ef2 --- /dev/null +++ b/learn_test/mylib/target/debug/mylib-8daa0161999f343d.d @@ -0,0 +1 @@ +/home/andy/source/rust/learn_rust/learn_test/mylib/target/debug/mylib-8daa0161999f343d: /home/andy/source/rust/learn_rust/learn_test/mylib/src/animal.rs /home/andy/source/rust/learn_rust/learn_test/mylib/src/lib.rs diff --git a/learn_test/src/main.rs b/learn_test/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/learn_test/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/learn_trait1/.gitignore b/learn_trait1/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_trait1/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_trait1/Cargo.lock b/learn_trait1/Cargo.lock new file mode 100644 index 00000000..56cddc4b --- /dev/null +++ b/learn_trait1/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_trait1" +version = "0.1.0" + diff --git a/learn_trait1/Cargo.toml b/learn_trait1/Cargo.toml new file mode 100644 index 00000000..13edcec5 --- /dev/null +++ b/learn_trait1/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_trait1" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_trait1/src/main.rs b/learn_trait1/src/main.rs new file mode 100644 index 00000000..a4fab199 --- /dev/null +++ b/learn_trait1/src/main.rs @@ -0,0 +1,78 @@ +//1、trait用于定义与其它类型共享的功能,类似于其它语言中的接口。 +//(1)可以通过trait以抽象的方式定义共享的行为。 +//(2)可以使用trait bounds指定泛型是任何拥有特定行为的类型。 +//2、定义trait +pub trait GetInformation { + fn get_name(&self) -> &String; + fn get_age(&self) -> u32; +} + +trait SchoolName { + fn get_school_name(&self) -> String { + String::from("HongXingSchool") + } +} + +//3、实现trait +pub struct Student { + pub name: String, + pub age: u32, +} + +impl SchoolName for Student {} + +impl GetInformation for Student { + fn get_name(&self) -> &String { + &self.name + } + + fn get_age(&self) -> u32 { + self.age + } +} + +pub struct Teacher { + pub name: String, + pub age: u32, + pub subject: String, +} + +impl SchoolName for Teacher{ + fn get_school_name(&self) -> String { + String::from("GuangmingSchool") + } +} + +impl GetInformation for Teacher{ + fn get_name(&self) -> &String { + &self.name + } + + fn get_age(&self) -> u32 { + self.age + } +} + +//4、默认实现:可以在定义trait的时候提供默认的行为,trait的类型可以使用默认的行为。 +//5、trait作为参数 +fn print_information(item: impl GetInformation) { + println!("name = {}", item.get_name()); + println!("age = {}", item.get_age()); +} + +fn main() { + let s = Student{name: "xiaoming".to_string(), age: 10}; + let t = Teacher{name: "xiaohuang".to_string(), age: 30, subject: String::from("math")}; + //println!("student, name = {}, age = {}", s.get_name(), s.get_age()); + //println!("teacher, name = {}, age = {}", t.get_name(), t.get_age()); + + let s_school_name = s.get_school_name(); + println!("student school name = {}", s_school_name); + let t_school_name = t.get_school_name(); + println!("teacher school name = {}", t_school_name); + + print_information(s); + print_information(t); + + println!("Hello, world!"); +} diff --git a/learn_trait2/.gitignore b/learn_trait2/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_trait2/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_trait2/Cargo.lock b/learn_trait2/Cargo.lock new file mode 100644 index 00000000..6fb8c7a5 --- /dev/null +++ b/learn_trait2/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_trait2" +version = "0.1.0" + diff --git a/learn_trait2/Cargo.toml b/learn_trait2/Cargo.toml new file mode 100644 index 00000000..48684cb3 --- /dev/null +++ b/learn_trait2/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_trait2" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_trait2/src/main.rs b/learn_trait2/src/main.rs new file mode 100644 index 00000000..71da0296 --- /dev/null +++ b/learn_trait2/src/main.rs @@ -0,0 +1,93 @@ +//1、trait_bound语法 +//2、指定多个trait bound +//3、返回 trait的类型 +//fn print_information(item: impl GetInformation) { //直接作为参数的写法 +//fn print_information(item: T){ //使用trait bound的写法 +// println!("name = {}", item.get_name()); +// println!("age = {}", item.get_age()); +//} + +trait GetName { + fn get_name(&self) -> &String; +} + +trait GetAge { + fn get_age(&self) -> u32; +} + +////写法一: +//fn print_information(item: T){ //使用trait bound的写法 +// println!("name = {}", item.get_name()); +// println!("age = {}", item.get_age()); +//} + +//写法二: +fn print_information(item: T) + where T: GetName+GetAge +{ //使用trait bound的写法 + println!("name = {}", item.get_name()); + println!("age = {}", item.get_age()); +} + +#[derive(Debug)] +pub struct Student { + pub name: String, + pub age: u32, +} + +impl GetName for Student { + fn get_name(&self) -> &String { + &self.name + } +} + +impl GetAge for Student { + fn get_age(&self) -> u32 { + self.age + } +} + +fn produce_item_with_age() -> impl GetAge { + Student { + name: String::from("xiaoming"), + age: 15, + } +} + +#[derive(Debug)] +pub struct Teacher{ + pub name: String, + pub age: u32, +} + +impl GetAge for Teacher { + fn get_age(&self) -> u32 { + self.age + } +} + +//错误的用法 +//fn produce_item_with_age2() -> impl GetAge { +// let is = true; +// +// if is { +// Student { +// name: String::from("xiaoming"), +// age: 15, +// } +// } else { +// Teacher { +// name: String::from("xiaohuang"), +// age: 15, +// } +// } +//} + +fn main() { + let s = Student{name: "xiaoming".to_string(), age: 10}; + print_information(s); + + let s = produce_item_with_age(); + + println!("Hello, world!"); +} diff --git a/learn_trait3/.gitignore b/learn_trait3/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_trait3/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_trait3/Cargo.lock b/learn_trait3/Cargo.lock new file mode 100644 index 00000000..3be02fa3 --- /dev/null +++ b/learn_trait3/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_trait3" +version = "0.1.0" + diff --git a/learn_trait3/Cargo.toml b/learn_trait3/Cargo.toml new file mode 100644 index 00000000..aeba5d5b --- /dev/null +++ b/learn_trait3/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_trait3" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_trait3/src/main.rs b/learn_trait3/src/main.rs new file mode 100644 index 00000000..5a88970c --- /dev/null +++ b/learn_trait3/src/main.rs @@ -0,0 +1,25 @@ +//fn largest (list: &[T]) -> T { +fn largest (list: &[T]) -> T + where T: PartialOrd + Copy +{ + let mut larger = list[0]; + for &item in list.iter() { + if item > larger { + larger = item; + } + } + larger +} + +fn main() { + let number_list = vec![1, 2, 23, 34, 8, 100]; + //let max_number = largest_i32(&number_list); + let max_number = largest(&number_list); + println!("max_number = {}", max_number); + + let char_list= vec!['a', 'y', 'b']; + //let max_char = largest_char(&char_list); + let max_char = largest(&char_list); + println!("max_char = {}", max_char); + println!("Hello, world!"); +} diff --git a/learn_trait4/.gitignore b/learn_trait4/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_trait4/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_trait4/Cargo.lock b/learn_trait4/Cargo.lock new file mode 100644 index 00000000..b06bd0b3 --- /dev/null +++ b/learn_trait4/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_trait4" +version = "0.1.0" + diff --git a/learn_trait4/Cargo.toml b/learn_trait4/Cargo.toml new file mode 100644 index 00000000..801866c7 --- /dev/null +++ b/learn_trait4/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_trait4" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_trait4/src/main.rs b/learn_trait4/src/main.rs new file mode 100644 index 00000000..b1bb2798 --- /dev/null +++ b/learn_trait4/src/main.rs @@ -0,0 +1,63 @@ +//使用trait bound有条件的实现方法 +trait GetName { + fn get_name(&self) -> &String; +} +trait GetAge { + fn get_age(&self) -> u32; +} +struct PeopleMatchInformation { + master: T, + student: U, +} +impl PeopleMatchInformation { + fn print_all_information(&self) { + println!("in print_all_information"); + println!("master name = {}", self.master.get_name()); + println!("master age = {}", self.master.get_age()); + println!("student name = {}", self.student.get_name()); + println!("student age = {}", self.student.get_age()); + } +} + +struct Teacher { + name: String, + age: u32, +} + +impl GetName for Teacher { + fn get_name(&self) -> &String { + &(self.name) + } +} + +impl GetAge for Teacher { + fn get_age(&self) -> u32 { + self.age + } +} + +struct Student{ + name: String, + age: u32, +} + +impl GetName for Student{ + fn get_name(&self) -> &String { + &(self.name) + } +} + +impl GetAge for Student{ + fn get_age(&self) -> u32 { + self.age + } +} + +fn main() { + let s = Student{name: "xiaoming".to_string(), age:15}; + let t = Teacher{name: "xiaohuang".to_string(), age:30}; + let m = PeopleMatchInformation{master: t, student: s}; + m.print_all_information(); + + println!("Hello, world!"); +} diff --git a/learn_trait5/.gitignore b/learn_trait5/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_trait5/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_trait5/Cargo.lock b/learn_trait5/Cargo.lock new file mode 100644 index 00000000..8b7710f2 --- /dev/null +++ b/learn_trait5/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_trait5" +version = "0.1.0" + diff --git a/learn_trait5/Cargo.toml b/learn_trait5/Cargo.toml new file mode 100644 index 00000000..6bfce14a --- /dev/null +++ b/learn_trait5/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_trait5" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_trait5/src/main.rs b/learn_trait5/src/main.rs new file mode 100644 index 00000000..30dfb853 --- /dev/null +++ b/learn_trait5/src/main.rs @@ -0,0 +1,30 @@ +//对任何实现了特定trait的类型有条件的实现trait +trait GetName { + fn get_name(&self) -> &String; +} + +trait PrintName { + fn print_name(&self); +} + +impl PrintName for T { + fn print_name(&self) { + println!("name = {}", self.get_name()); + } +} + +struct Student { + name: String, +} + +impl GetName for Student { + fn get_name(&self) -> &String { + &(self.name) + } +} + +fn main() { + let s = Student{name: String::from("xiaohuang")}; + s.print_name(); + println!("Hello, world!"); +} diff --git a/learn_type/.gitignore b/learn_type/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_type/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_type/Cargo.lock b/learn_type/Cargo.lock new file mode 100644 index 00000000..f93a64b9 --- /dev/null +++ b/learn_type/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_type" +version = "0.1.0" + diff --git a/learn_type/Cargo.toml b/learn_type/Cargo.toml new file mode 100644 index 00000000..fafae696 --- /dev/null +++ b/learn_type/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_type" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_type/src/main.rs b/learn_type/src/main.rs new file mode 100644 index 00000000..09f6e9e3 --- /dev/null +++ b/learn_type/src/main.rs @@ -0,0 +1,57 @@ +fn main() { + //bool + let is_true: bool = true; + println!("is_true = {}", is_true); + + let is_false = false; + println!("is_false = {}, {}", is_false, is_true); + + //char 在rust里面,char是32位的 + let a = 'a'; + println!("a = {}", a); + + let b = '你'; + println!("b = {}", b); + + //i8, i16, i32, i64, u8, u16, u32, u64, f32, f64 + let c: i8 = -111; + println!("c = {}", c); + + let d: f32 = 0.0009; + println!("d = {}", d); + + //自适应类型isize, usize + println!("max = {}", usize::max_value()); + + //数组 + //[Type; size] , size 也是数组类型的一部分 + let arr: [u32; 5] = [1, 2, 3, 4, 5]; + let arr1: [u32; 3] = [1, 2, 3]; + println!("arr[0] = {}", arr[0]); + + show(arr1); + + //元组 + let tup: (i32, f32, char) = (-3, 3.69, '好'); + let tup = (-3, 3.69, '好'); + println!("--------------------"); + println!("{}", tup.0); + println!("{}", tup.1); + println!("{}", tup.2); + println!("--------------------"); + + let (x, y, z) = tup; + println!("{}", x); + println!("{}", y); + println!("{}", z); + + println!("Hello, world!"); +} + +fn show(arr:[u32;3]) { + println!("--------------------"); + for i in &arr { + println!("{}", i); + } + println!("--------------------"); +} diff --git a/learn_var/.gitignore b/learn_var/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_var/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_var/Cargo.lock b/learn_var/Cargo.lock new file mode 100644 index 00000000..182ec2d5 --- /dev/null +++ b/learn_var/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_var" +version = "0.1.0" + diff --git a/learn_var/Cargo.toml b/learn_var/Cargo.toml new file mode 100644 index 00000000..124548f7 --- /dev/null +++ b/learn_var/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_var" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_var/src/main.rs b/learn_var/src/main.rs new file mode 100644 index 00000000..431c2a00 --- /dev/null +++ b/learn_var/src/main.rs @@ -0,0 +1,23 @@ +const MAX_POINTS: u32 = 100000; +fn main() { + //1、变量定义 + //定义变量用let,如果变量没有用mut,那么是不可变的 + //let name: type + let a = 1; + //let a:u32 = 1; + println!("a = {}", a); + + let mut b: u32 = 1; + println!("b = {}", b); + + b = 2; + println!("b = {}", b); + + //2、隐藏 + let b: f32 = 1.1; + println!("b = {}", b); + + //3、常量 + println!("MAX_POINTS = {}", MAX_POINTS); + println!("Hello, world!"); +} diff --git a/learn_vector/.gitignore b/learn_vector/.gitignore new file mode 100644 index 00000000..53eaa219 --- /dev/null +++ b/learn_vector/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/learn_vector/Cargo.lock b/learn_vector/Cargo.lock new file mode 100644 index 00000000..b0074ffb --- /dev/null +++ b/learn_vector/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "learn_vector" +version = "0.1.0" + diff --git a/learn_vector/Cargo.toml b/learn_vector/Cargo.toml new file mode 100644 index 00000000..6f88915c --- /dev/null +++ b/learn_vector/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "learn_vector" +version = "0.1.0" +authors = ["andy"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/learn_vector/src/main.rs b/learn_vector/src/main.rs new file mode 100644 index 00000000..f227685f --- /dev/null +++ b/learn_vector/src/main.rs @@ -0,0 +1,76 @@ +//1、创建空的vector: Vec +//2、创建包含初始值的vector +//3、丢弃vector +//4、读取元素 +//5、更新 +//6、遍历 +//7、使用枚举 +fn main() { + //1 + //let v: Vec = Vec::new(); + let mut v: Vec = Vec::new(); + //v.push(1); + + //2 + let v = vec![1, 2, 3]; + + //3 + { + let v1 = vec![1, 2, 3]; + } + + //4 + let one: &i32 = &v[0]; + //let four: &i32 = &v[3]; + println!("one = {}", one); + println!("one = {}", *one); + + //(2)推荐的方法 + //match v.get(1) { + match v.get(3) { + Some(value) => println!("value = {}", value), + _ => println!("None"), + } + + //5 + let mut v2: Vec = Vec::new(); + v2.push(1); + v2.push(2); + v2.push(3); + + //6 + //(1)不可变的遍历 + for i in &v2 { + println!("i = {}", i); + } + + //(2)可变的遍历 + for i in &mut v2 { + *i += 1; + println!("i = {}", i); + } + + + //7 + enum Context { + Text(String), + Float(f32), + Int(i32), + }; + + let c = vec![ + Context::Text(String::from("string")), + Context::Int(-1), + Context::Float(0.001) + ]; + + + + //8、补充 + let mut v = vec![1, 2, 3, 4, 5]; + let first = &v[0]; + v.push(6); + println!("first = {}", first); + + println!("Hello, world!"); +} diff --git a/t.rs b/t.rs new file mode 100644 index 00000000..958bad80 --- /dev/null +++ b/t.rs @@ -0,0 +1,13 @@ +//1、指针是一个包含内存地址的变量。这个地址指向一些其它的数据。 +// 智能指针是一类数据结构,它们表现类似于指针,但是也拥有额外的元数据,最明显的,它们拥有一个引用计数。引用计数记录智能指针总共有多少个所有者,并且当没有任何所有者时清除数据。 +// 普通引用和智能指针的一个额外区别是:引用只是只借用数据的指针,而智能指针则是拥有它们指向的数据。 +// +//2、智能指针通常使用结构体实现。智能指针区别于常规结构体的显著特征在于其实现了Deref和Drop trait。 +//(1)Deref trait允许智能指针结构体实例表现的像引用一样,这样就可以编写即用于引用,又用于智能指针的代码。 +//(2)Drop trait允许我们自定义当智能指针离开作用域时执行的代码。 +// +//3、几个标准库中的智能指针: +//Box,用于在堆上分配; +//Rc,一个引用计数类型,其数据可以有多个所有者; +//Ref和RefMut,通过RefCell,一个在运行时而不是在编译时执行借用规则的类型。 +