mirror of
https://github.com/darkicewolf50/RustBrock.git
synced 2025-06-15 13:04:18 -06:00
ch7.0 + 7.1 finished
This commit is contained in:
parent
2bb6f5f969
commit
5725ea4a90
40
.obsidian/workspace.json
vendored
40
.obsidian/workspace.json
vendored
@ -27,12 +27,27 @@
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Modules.md",
|
||||
"file": "Project Organization.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "Modules"
|
||||
"title": "Project Organization"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "773e0725828dabb7",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Crates.md",
|
||||
"mode": "source",
|
||||
"backlinks": false,
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "Crates"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -50,7 +65,7 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"currentTab": 1
|
||||
"currentTab": 2
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
@ -106,7 +121,7 @@
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 300
|
||||
"width": 241.5
|
||||
},
|
||||
"right": {
|
||||
"id": "b825b33a537311a6",
|
||||
@ -192,14 +207,19 @@
|
||||
"command-palette:Open command palette": false
|
||||
}
|
||||
},
|
||||
"active": "b80f5219fa24358f",
|
||||
"active": "773e0725828dabb7",
|
||||
"lastOpenFiles": [
|
||||
"data_types.md",
|
||||
"Modules.md",
|
||||
"Data Types.md",
|
||||
"Primitives.md",
|
||||
"ownership.md",
|
||||
"Packages.md",
|
||||
"Crates.md",
|
||||
"Project Organization.md",
|
||||
"Enums.md",
|
||||
"Primitives.md",
|
||||
"Packages and Crates.md",
|
||||
"Good and Bad Code/Commenting Pratices",
|
||||
"Good and Bad Code",
|
||||
"data_types.md",
|
||||
"Data Types.md",
|
||||
"ownership.md",
|
||||
"Variables.md",
|
||||
"README.md",
|
||||
"Untitled.canvas",
|
||||
|
33
Crates.md
Normal file
33
Crates.md
Normal file
@ -0,0 +1,33 @@
|
||||
# Crates
|
||||
The smallest amount of code that the rust compiler will consider
|
||||
|
||||
This includes single binary exe files compiled with ``rustc``
|
||||
|
||||
``cargo build`` also counts and so does ``cargo run`` (implicit ``cargo build``)
|
||||
|
||||
Crates can contain modules and modules may be defined in other files that get compiled with the crate
|
||||
|
||||
It comes in two forms a library or a binary
|
||||
|
||||
## Binary Crates
|
||||
are programs that can be compiled then run like a cli application or a server
|
||||
each must have main function that defines what happens when the executable runs
|
||||
|
||||
## Library Crates
|
||||
are programs that don't have a main function and don't compile to a executable
|
||||
instead it defines functionality that is intended to be shared with multiple projects
|
||||
|
||||
most of the time when the term "crate" is said it means a library crate
|
||||
and crate is used interchangeably with the term library with other languages
|
||||
|
||||
|
||||
## Root Crate
|
||||
this is the source file that the compiler starts from and makes up the root module of your crate
|
||||
|
||||
this is normally src/main.rs in a binary crate
|
||||
scr/lib.rs is normally the root in a library crate with the same name as the package
|
||||
hence why it doesn't need to be mentioned in the toml file this tells you what the packages are
|
||||
|
||||
cargo passes root crates to rustc to build the library or the binary
|
||||
|
||||
by replacing files in the src/bin directory each file will be its own binary crate
|
@ -1 +0,0 @@
|
||||
# Modules
|
11
Packages.md
Normal file
11
Packages.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Packages
|
||||
|
||||
a bundle of one or more crates that provides a set functionality
|
||||
|
||||
it contains a cargo.toml file and describes how to build those crates
|
||||
|
||||
packages can have as many binary crates as you want but only at most one library crate
|
||||
|
||||
packages must have at least one crate
|
||||
|
||||
packages are defined by the toml file that comes with creating a new crate
|
18
Project Organization.md
Normal file
18
Project Organization.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Packages, Modules and Crates
|
||||
|
||||
Projects should generally group related code/function together this increases code organization
|
||||
|
||||
packages can contain multiple binary codes/files or a library crate
|
||||
|
||||
very large projects should be done with interrelated packages that all update should be done using cargo workspaces
|
||||
|
||||
encapsulation is useful because you don't need to worry about its implementation
|
||||
this is good for reusing code
|
||||
|
||||
rust has features for your code's organization, which parts are exposed, which details are private and what names are in each scope in the program
|
||||
|
||||
These features are known collectively as the ``module system`` they include
|
||||
- [**Packages**](Packages.md): A feature of Cargo that allows you to build, test and share crates
|
||||
- [**Crates**](Crates.md): A tree of modules that produces a library or an executable
|
||||
- **Modules** and **use**: lets you control the organization, scope and privacy of paths
|
||||
- **Paths**: A way of naming an item, such as a struct, function or module
|
@ -1 +1 @@
|
||||
{"rustc_fingerprint":13662911779824945272,"outputs":{"12744816824612481171":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Brock\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.83.0 (90b35a623 2024-11-26)\nbinary: rustc\ncommit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\ncommit-date: 2024-11-26\nhost: x86_64-pc-windows-msvc\nrelease: 1.83.0\nLLVM version: 19.1.1\n","stderr":""},"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Brock\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\nfmt_debug=\"full\"\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"lahfsahf\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"128\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"pc\"\nub_checks\nwindows\n","stderr":""}},"successes":{}}
|
||||
{"rustc_fingerprint":13662911779824945272,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Brock\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\nfmt_debug=\"full\"\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"lahfsahf\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"128\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"128\"\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"pc\"\nub_checks\nwindows\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.83.0 (90b35a623 2024-11-26)\nbinary: rustc\ncommit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf\ncommit-date: 2024-11-26\nhost: x86_64-pc-windows-msvc\nrelease: 1.83.0\nLLVM version: 19.1.1\n","stderr":""},"12744816824612481171":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\Brock\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}}
|
Loading…
x
Reference in New Issue
Block a user