diff --git a/rust-book/chapter-1/guessing_game/.gitignore b/rust-book/chapter-1/guessing_game/.gitignore new file mode 100644 index 0000000..53eaa21 --- /dev/null +++ b/rust-book/chapter-1/guessing_game/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/rust-book/chapter-1/guessing_game/Cargo.lock b/rust-book/chapter-1/guessing_game/Cargo.lock new file mode 100644 index 0000000..959e92c --- /dev/null +++ b/rust-book/chapter-1/guessing_game/Cargo.lock @@ -0,0 +1,91 @@ +# 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 = "guessing_game" +version = "0.1.0" +dependencies = [ + "rand 0.3.23 (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 = "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 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 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/rust-book/chapter-1/guessing_game/Cargo.toml b/rust-book/chapter-1/guessing_game/Cargo.toml new file mode 100644 index 0000000..237179e --- /dev/null +++ b/rust-book/chapter-1/guessing_game/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "guessing_game" +version = "0.1.0" +authors = ["dtomlinson "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rand = "0.3.14" diff --git a/rust-book/chapter-1/guessing_game/src/main.rs b/rust-book/chapter-1/guessing_game/src/main.rs new file mode 100644 index 0000000..eca8308 --- /dev/null +++ b/rust-book/chapter-1/guessing_game/src/main.rs @@ -0,0 +1,15 @@ +use std::io; + +fn main() { + println!("Guess the number!"); + + println!("Please input your guess."); + + let mut guess = String::new(); + + io::stdin().read_line(&mut guess) + .expect("Failed to read line"); + + + println!("You guessed: {}", guess); +} diff --git a/rust-book/chapter-1/hello_cargo/.gitignore b/rust-book/chapter-1/hello_cargo/.gitignore new file mode 100644 index 0000000..53eaa21 --- /dev/null +++ b/rust-book/chapter-1/hello_cargo/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/rust-book/chapter-1/hello_cargo/Cargo.lock b/rust-book/chapter-1/hello_cargo/Cargo.lock new file mode 100644 index 0000000..534dc59 --- /dev/null +++ b/rust-book/chapter-1/hello_cargo/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "hello_cargo" +version = "0.1.0" + diff --git a/rust-book/chapter-1/hello_cargo/Cargo.toml b/rust-book/chapter-1/hello_cargo/Cargo.toml new file mode 100644 index 0000000..c168b4e --- /dev/null +++ b/rust-book/chapter-1/hello_cargo/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "hello_cargo" +version = "0.1.0" +authors = ["dtomlinson "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/rust-book/chapter-1/hello_cargo/src/main.rs b/rust-book/chapter-1/hello_cargo/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/rust-book/chapter-1/hello_cargo/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/rust-book/chapter-1/hello_world/main b/rust-book/chapter-1/hello_world/main new file mode 100755 index 0000000..e1a8033 Binary files /dev/null and b/rust-book/chapter-1/hello_world/main differ diff --git a/rust-book/chapter-1/hello_world/main.rs b/rust-book/chapter-1/hello_world/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/rust-book/chapter-1/hello_world/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/rust-book/notes.txt b/rust-book/notes.txt new file mode 100644 index 0000000..b7ebf15 --- /dev/null +++ b/rust-book/notes.txt @@ -0,0 +1,8 @@ +Rustbook - notes + +set USER env var to "dtomlinson " + +Q: How can we check what a method/fn returns in rust? +eg readline returns Result, how do we know this in advance? + +Q: is there something like dir() in python? diff --git a/rust-book/todo.txt b/rust-book/todo.txt new file mode 100644 index 0000000..40b5f1b --- /dev/null +++ b/rust-book/todo.txt @@ -0,0 +1,11 @@ +To do: + +- Update sublime packages/configs with cargo + - rust-extended, toml, lsp +- Document rls for sublime + - using rustup, lsp (sublime) + - https://github.com/rust-lang/rust-enhanced (RLS section) +- Go through https://darrenburns.net/posts/tools/ + +-rustup install nightly-x86_64-apple-darwin +-rustup component add rls --toolchain nightly-x86_64-apple-darwin