Skip to content

Commit

Permalink
reorganisation of folder contents
Browse files Browse the repository at this point in the history
  • Loading branch information
rakurame96 committed Mar 26, 2024
1 parent a93a9a2 commit b1b0b93
Show file tree
Hide file tree
Showing 34 changed files with 22 additions and 524 deletions.
4 changes: 2 additions & 2 deletions projects/README.md → book-examples/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Projects section
### Book Examples section

* Covers projects from the book
* Covers examples code snippet from the book
* Book: The Rust Programming Language by Steve Klabnik & Carol Nichols

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "day4"
name = "ch3-constants"
version = "0.1.0"
edition = "2021"

Expand Down
10 changes: 10 additions & 0 deletions book-examples/ch3-constants/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// consts GLOBAL_CONST = 180; // compile error as constants always needs to be annotated with the datatype
const GLOBAL_CONST: u32 = 180;

fn main() {
println!("Value of global constant variable = {}", GLOBAL_CONST);

const LOCAL_CONST: f32 = 0.001;

println!("Value of local constant variable = {}", LOCAL_CONST);
}
17 changes: 0 additions & 17 deletions inpyjama-30-days-of-rust/Cargo.toml

This file was deleted.

10 changes: 9 additions & 1 deletion inpyjama-30-days-of-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ This is how Rust ensures memory safety – by refusing to compile code that coul

##### Constants and Statics
**Consts** are essentially fixed values known at compile time. They must have a type annotation and are perfect for situations like array sizes or mathematical constants. They behave similarly to #define macros in C, but are type-safe and prevent unexpected behavior
* Const can be defined in both local and global scope.
* Const must be annotated with the datatype unlike the other variables
* Rust suggested way of creating constants is, all uppercase with underscores between words
```rust
// consts GLOBAL_CONST = 180; // compile error as constants always needs to be annotated with the datatype
const GLOBAL_CONST: u32 = 180;
```

**Statics** are similar to const, but they have a fixed memory location throughout the program's execution. This makes them useful for global variables that need to persist, like configuration settings or file handles. However, unlike const, statics can't be used in all contexts (like within functions) due to their global nature.

Expand Down Expand Up @@ -205,4 +212,5 @@ Arrays are a fundamental data structure that allow us to store multiple values o
7. [Day 6: Variables Continued](https://inpyjama.com/day6-variables-contd/)
8. [Day 7: Rust hate Implicit](https://inpyjama.com/day7-rust-hate-implicits/)
9. [Day 8: Tuples](https://inpyjama.com/day-8-tuples/)
10. [Day 9: Arrays](https://inpyjama.com/day-9-arrays/)
10. [Day 9: Arrays](https://inpyjama.com/day-9-arrays/)
11. [Day 10: Heap vs Stack](https://inpyjama.com/day-10-heap-vs-stack/)
8 changes: 0 additions & 8 deletions inpyjama-30-days-of-rust/day10/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions inpyjama-30-days-of-rust/day10/src/main.rs

This file was deleted.

8 changes: 0 additions & 8 deletions inpyjama-30-days-of-rust/day2/hello/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions inpyjama-30-days-of-rust/day2/hello/src/main.rs

This file was deleted.

5 changes: 0 additions & 5 deletions inpyjama-30-days-of-rust/day2/helloworld/README.md

This file was deleted.

Binary file removed inpyjama-30-days-of-rust/day2/helloworld/main.exe
Binary file not shown.
3 changes: 0 additions & 3 deletions inpyjama-30-days-of-rust/day2/helloworld/main.rs

This file was deleted.

8 changes: 0 additions & 8 deletions inpyjama-30-days-of-rust/day3/Cargo.toml

This file was deleted.

28 changes: 0 additions & 28 deletions inpyjama-30-days-of-rust/day3/src/main.rs

This file was deleted.

7 changes: 0 additions & 7 deletions inpyjama-30-days-of-rust/day4/README.md

This file was deleted.

36 changes: 0 additions & 36 deletions inpyjama-30-days-of-rust/day4/src/main.rs

This file was deleted.

8 changes: 0 additions & 8 deletions inpyjama-30-days-of-rust/day5/Cargo.toml

This file was deleted.

25 changes: 0 additions & 25 deletions inpyjama-30-days-of-rust/day5/README.md

This file was deleted.

Binary file removed inpyjama-30-days-of-rust/day5/src/main.exe
Binary file not shown.
33 changes: 0 additions & 33 deletions inpyjama-30-days-of-rust/day5/src/main.rs

This file was deleted.

8 changes: 0 additions & 8 deletions inpyjama-30-days-of-rust/day6/Cargo.toml

This file was deleted.

35 changes: 0 additions & 35 deletions inpyjama-30-days-of-rust/day6/README.md

This file was deleted.

18 changes: 0 additions & 18 deletions inpyjama-30-days-of-rust/day6/src/main.rs

This file was deleted.

8 changes: 0 additions & 8 deletions inpyjama-30-days-of-rust/day7/Cargo.toml

This file was deleted.

15 changes: 0 additions & 15 deletions inpyjama-30-days-of-rust/day7/src/main.rs

This file was deleted.

8 changes: 0 additions & 8 deletions inpyjama-30-days-of-rust/day8/Cargo.toml

This file was deleted.

Loading

0 comments on commit b1b0b93

Please sign in to comment.