From 1c09fc9f91e7afc24e6d481fb29e918bb05f81c9 Mon Sep 17 00:00:00 2001 From: Rakuram Date: Sun, 21 Jul 2024 10:21:02 +0530 Subject: [PATCH] update projects --- README.md | 7 ++++--- inpyjama-30-days-of-rust/README.md | 4 ++++ projects/Cargo.toml | 2 +- projects/macro_rules/Cargo.toml | 6 ++++++ projects/macro_rules/src/lib.rs | 32 ++++++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 projects/macro_rules/Cargo.toml create mode 100644 projects/macro_rules/src/lib.rs diff --git a/README.md b/README.md index 48a68d3..c90a568 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ A small selection of other guides and tutorial for Rust: - [Collection of traits which describe functionality of cryptographic primitives](https://github.com/RustCrypto/traits/tree/master) - [Algorithms and Data Structures of all kinds written in Rust](https://github.com/alexfertel/rust-algorithms) - [The Little Book of Rust Macros](https://danielkeep.github.io/tlborm/book/README.html) -- [Gray-Scott with Rust](https://grayscott-with-rust-grasland-5e6591fc7054976525da4f6c87122ea76c.pages.in2p3.fr/) +- [Gray-Scott with Rust - Writing High Performance Computing (HPC) in Rust!](https://grayscott-with-rust-grasland-5e6591fc7054976525da4f6c87122ea76c.pages.in2p3.fr/) ## Online Articles @@ -77,7 +77,7 @@ A small selection of other guides and tutorial for Rust: - [The missing parts in Cargo](https://weihanglo.tw/posts/2024/the-missing-parts-in-cargo/) - [Build with Naz : Box and Pin exploration in Rust](https://developerlife.com/2024/07/16/pin-box-dynamic-duo/) -## YouTube Videos to look for +## YouTube Videos to look for (what I watched until now) - [All Rust features explained](https://www.youtube.com/watch?v=784JWR4oxOI) - [Visualizing memory layout of Rust's data types](https://www.youtube.com/watch?v=7_o-YRxf_cc) - ["Intro to Monads for Rustaceans" (July 2022)](https://www.youtube.com/watch?v=4Ky8kvDcshg) @@ -86,6 +86,7 @@ A small selection of other guides and tutorial for Rust: - [Understanding Rust Closures aka. Anonymous Functions 🦀 💻](https://www.youtube.com/watch?v=qXNUHfpalts) - [Rust Match Expressions and Patterns 🦀](https://www.youtube.com/watch?v=pf8eQwWkTaY) - [Decrusting the serde crate](https://www.youtube.com/watch?v=BI_bHCGRgMY) +- [How Rust's println! macro really works](https://www.youtube.com/watch?v=WB0l1_YbHok) ## Rust Books Recommendation - Claus Matzinger • Learn Rust Programming • https://amzn.to/3PeN0Fx @@ -97,7 +98,7 @@ A small selection of other guides and tutorial for Rust: - Ken Youens-Clark • Command-Line Rust • https://amzn.to/3PQZ539 - Kevin Hoffman • Programming WebAssembly with Rust • https://amzn.to/3x3brhe - [Practical Cryptography for Developers](https://cryptobook.nakov.com/) - - [Explained from First Principles - Number Theory](https://explained-from-first-principles.com/number-theory/) +- [Explained from First Principles - Number Theory](https://explained-from-first-principles.com/number-theory/) - [Cryptography in Rust for Hackers](https://cryptographyinrustforhackers.com/index.html) Please see the [Little Book of Rust Books](https://lborb.github.io/book/) for even more Rust books. diff --git a/inpyjama-30-days-of-rust/README.md b/inpyjama-30-days-of-rust/README.md index 22c4769..294e98b 100644 --- a/inpyjama-30-days-of-rust/README.md +++ b/inpyjama-30-days-of-rust/README.md @@ -55,6 +55,10 @@ cargo new restaurant --lib --vcs none rustfmt <.\file_name.rs> ``` +```shell +cargo expand --lib --tests +``` + > **_NOTE: Ruslings Commands_** Commands available to you in watch mode: * `hint` - prints the current exercise's hint diff --git a/projects/Cargo.toml b/projects/Cargo.toml index 724de66..e91f4da 100644 --- a/projects/Cargo.toml +++ b/projects/Cargo.toml @@ -2,5 +2,5 @@ resolver = "2" members = [ - "guessing-game", "strsplit", "uds-simulator/uds-simulator", + "guessing-game", "macro_rules", "strsplit", "uds-simulator/uds-simulator", "vec_macro", ] diff --git a/projects/macro_rules/Cargo.toml b/projects/macro_rules/Cargo.toml new file mode 100644 index 0000000..66bdfd5 --- /dev/null +++ b/projects/macro_rules/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "macro_rules" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/projects/macro_rules/src/lib.rs b/projects/macro_rules/src/lib.rs new file mode 100644 index 0000000..e84df1f --- /dev/null +++ b/projects/macro_rules/src/lib.rs @@ -0,0 +1,32 @@ +use std::io::Write; + +macro_rules! my_println { + ($x: expr) => { + let _ = writeln!(std::io::stdout(), "{}", $x); + }; +} + +macro_rules! my_println_with_args { + ($($args:tt)*) => { + let _ = writeln!(std::io::stdout(), "{}", format_args!($($args)*)); + }; +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let name = "Rakuram"; + // assert_eq!(result, 4); + my_println!("Hello!"); + my_println_with_args!("Hello, {}!", name); + } + + // #[test] + // fn it_doesnot_works() { + // let result = square!(2); + // assert_eq!(result, 6); + // } +}