Compare commits
2 Commits
df0bcf7ab7
...
e9abf4b203
| Author | SHA1 | Date | |
|---|---|---|---|
| e9abf4b203 | |||
| b73834b5b5 |
7
1-hello-world/debug/Cargo.lock
generated
Normal file
7
1-hello-world/debug/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "debug"
|
||||
version = "0.1.0"
|
||||
6
1-hello-world/debug/Cargo.toml
Normal file
6
1-hello-world/debug/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "debug"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
BIN
1-hello-world/debug/main
Executable file
BIN
1-hello-world/debug/main
Executable file
Binary file not shown.
49
1-hello-world/debug/src/main.rs
Normal file
49
1-hello-world/debug/src/main.rs
Normal file
@ -0,0 +1,49 @@
|
||||
// This structure cannot be printed either with `fmt::Display` or
|
||||
// with `fmt::Debug`.
|
||||
struct UnPrintable(i32);
|
||||
|
||||
// The `derive` attribute automatically creates the implementation
|
||||
// required to make this `struct` printable with `fmt::Debug`.
|
||||
#[derive(Debug)]
|
||||
struct DebugPrintable(i32);
|
||||
|
||||
// Derive the `fmt::Debug` implementation for `Structure`. `Structure`
|
||||
// is a structure which contains a single `i32`.
|
||||
#[derive(Debug)]
|
||||
struct Structure(i32);
|
||||
|
||||
// Put a `Structure` inside of the structure `Deep`. Make it printable
|
||||
// also.
|
||||
#[derive(Debug)]
|
||||
struct Deep(Structure);
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Person<'a> {
|
||||
name: &'a str,
|
||||
age: u8
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Printing with `{:?}` is similar to with `{}`.
|
||||
println!("{:?} months in a year.", 12);
|
||||
println!("{1:?} {0:?} is the {actor:?} name.",
|
||||
"Slater",
|
||||
"Christian",
|
||||
actor="actor's");
|
||||
|
||||
// `Structure` is printable!
|
||||
println!("Now {:?} will print!", Structure(3));
|
||||
|
||||
// The problem with `derive` is there is no control over how
|
||||
// the results look. What if I want this to just show a `7`?
|
||||
println!("Now {:?} will print!", Deep(Structure(7)));
|
||||
|
||||
// `fmt::Debug` deinitely makes this printable but sacrifice some elegance.
|
||||
// Rust also provide "pretty print" with `{:#?}`.
|
||||
let name = "Peter";
|
||||
let age = 27;
|
||||
let peter = Person { name, age };
|
||||
|
||||
// Pretty print
|
||||
println!("{:#?}", peter);
|
||||
}
|
||||
1
1-hello-world/debug/target/.rustc_info.json
Normal file
1
1-hello-world/debug/target/.rustc_info.json
Normal file
@ -0,0 +1 @@
|
||||
{"rustc_fingerprint":14802351894921902018,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/nak/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_primitive_alignment=\"16\"\ntarget_has_atomic_primitive_alignment=\"32\"\ntarget_has_atomic_primitive_alignment=\"64\"\ntarget_has_atomic_primitive_alignment=\"8\"\ntarget_has_atomic_primitive_alignment=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"1847801304416329599":{"success":true,"status":"","code":0,"stdout":"rustc 1.98.1 (48a229cea 2026-09-01)\nbinary: rustc\ncommit-hash: 48a229ceaefd4985c50990b14116b6d856af0985\ncommit-date: 2026-09-01\nhost: x86_64-unknown-linux-gnu\nrelease: 1.98.1\nLLVM version: 22.1.8\n","stderr":""}},"successes":{}}
|
||||
3
1-hello-world/debug/target/CACHEDIR.TAG
Normal file
3
1-hello-world/debug/target/CACHEDIR.TAG
Normal file
@ -0,0 +1,3 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by cargo.
|
||||
# For information about cache directory tags see https://bford.info/cachedir/
|
||||
0
1-hello-world/debug/target/debug/.cargo-build-lock
Normal file
0
1-hello-world/debug/target/debug/.cargo-build-lock
Normal file
0
1-hello-world/debug/target/debug/.cargo-lock
Normal file
0
1-hello-world/debug/target/debug/.cargo-lock
Normal file
@ -0,0 +1 @@
|
||||
dc3015345aa383a3
|
||||
@ -0,0 +1 @@
|
||||
{"rustc":1625334936438085654,"features":"[]","declared_features":"[]","target":2484616488665672794,"profile":8731458305071235362,"path":4942398508502643691,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/debug-5a1b483393417d95/dep-bin-debug","checksum":false}}],"rustflags":[],"config":9396254390672932401,"compile_kind":0}
|
||||
Binary file not shown.
@ -0,0 +1 @@
|
||||
This file has an mtime of when this was started.
|
||||
@ -0,0 +1,6 @@
|
||||
{"$message_type":"diagnostic","message":"struct `UnPrintable` is never constructed","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":95,"byte_end":106,"line_start":3,"line_end":3,"column_start":8,"column_end":19,"is_primary":true,"text":[{"text":"struct UnPrintable(i32);","highlight_start":8,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: struct `UnPrintable` is never constructed\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:3:8\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m3\u001b[0m \u001b[1m\u001b[94m|\u001b[0m struct UnPrintable(i32);\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default\n\n"}
|
||||
{"$message_type":"diagnostic","message":"struct `DebugPrintable` is never constructed","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":268,"byte_end":282,"line_start":8,"line_end":8,"column_start":8,"column_end":22,"is_primary":true,"text":[{"text":"struct DebugPrintable(i32);","highlight_start":8,"highlight_end":22}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: struct `DebugPrintable` is never constructed\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:8:8\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m8\u001b[0m \u001b[1m\u001b[94m|\u001b[0m struct DebugPrintable(i32);\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^^^^^^\u001b[0m\n\n"}
|
||||
{"$message_type":"diagnostic","message":"field `0` is never read","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":434,"byte_end":443,"line_start":13,"line_end":13,"column_start":8,"column_end":17,"is_primary":false,"text":[{"text":"struct Structure(i32);","highlight_start":8,"highlight_end":17}],"label":"field in this struct","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/main.rs","byte_start":444,"byte_end":447,"line_start":13,"line_end":13,"column_start":18,"column_end":21,"is_primary":true,"text":[{"text":"struct Structure(i32);","highlight_start":18,"highlight_end":21}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider removing this field","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"`Structure` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: field `0` is never read\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:13:18\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m13\u001b[0m \u001b[1m\u001b[94m|\u001b[0m struct Structure(i32);\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m---------\u001b[0m \u001b[1m\u001b[33m^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94mfield in this struct\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mhelp\u001b[0m: consider removing this field\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `Structure` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis\n\n"}
|
||||
{"$message_type":"diagnostic","message":"field `0` is never read","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":555,"byte_end":559,"line_start":18,"line_end":18,"column_start":8,"column_end":12,"is_primary":false,"text":[{"text":"struct Deep(Structure);","highlight_start":8,"highlight_end":12}],"label":"field in this struct","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/main.rs","byte_start":560,"byte_end":569,"line_start":18,"line_end":18,"column_start":13,"column_end":22,"is_primary":true,"text":[{"text":"struct Deep(Structure);","highlight_start":13,"highlight_end":22}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"consider removing this field","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"`Deep` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: field `0` is never read\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:18:13\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m18\u001b[0m \u001b[1m\u001b[94m|\u001b[0m struct Deep(Structure);\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m----\u001b[0m \u001b[1m\u001b[33m^^^^^^^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94mfield in this struct\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mhelp\u001b[0m: consider removing this field\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `Deep` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis\n\n"}
|
||||
{"$message_type":"diagnostic","message":"fields `name` and `age` are never read","code":{"code":"dead_code","explanation":null},"level":"warning","spans":[{"file_name":"src/main.rs","byte_start":597,"byte_end":603,"line_start":21,"line_end":21,"column_start":8,"column_end":14,"is_primary":false,"text":[{"text":"struct Person<'a> {","highlight_start":8,"highlight_end":14}],"label":"fields in this struct","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/main.rs","byte_start":614,"byte_end":618,"line_start":22,"line_end":22,"column_start":5,"column_end":9,"is_primary":true,"text":[{"text":" name: &'a str,","highlight_start":5,"highlight_end":9}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"src/main.rs","byte_start":633,"byte_end":636,"line_start":23,"line_end":23,"column_start":5,"column_end":8,"is_primary":true,"text":[{"text":" age: u8","highlight_start":5,"highlight_end":8}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`Person` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: fields `name` and `age` are never read\u001b[0m\n \u001b[1m\u001b[94m--> \u001b[0msrc/main.rs:22:5\n \u001b[1m\u001b[94m|\u001b[0m\n\u001b[1m\u001b[94m21\u001b[0m \u001b[1m\u001b[94m|\u001b[0m struct Person<'a> {\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[94m------\u001b[0m \u001b[1m\u001b[94mfields in this struct\u001b[0m\n\u001b[1m\u001b[94m22\u001b[0m \u001b[1m\u001b[94m|\u001b[0m name: &'a str,\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^^\u001b[0m\n\u001b[1m\u001b[94m23\u001b[0m \u001b[1m\u001b[94m|\u001b[0m age: u8\n \u001b[1m\u001b[94m|\u001b[0m \u001b[1m\u001b[33m^^^\u001b[0m\n \u001b[1m\u001b[94m|\u001b[0m\n \u001b[1m\u001b[94m= \u001b[0m\u001b[1mnote\u001b[0m: `Person` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis\n\n"}
|
||||
{"$message_type":"diagnostic","message":"5 warnings emitted","code":null,"level":"warning","spans":[],"children":[],"rendered":"\u001b[1m\u001b[33mwarning\u001b[0m\u001b[1m: 5 warnings emitted\u001b[0m\n\n"}
|
||||
BIN
1-hello-world/debug/target/debug/debug
Executable file
BIN
1-hello-world/debug/target/debug/debug
Executable file
Binary file not shown.
1
1-hello-world/debug/target/debug/debug.d
Normal file
1
1-hello-world/debug/target/debug/debug.d
Normal file
@ -0,0 +1 @@
|
||||
/home/nak/Code/rust/learn-rust/debug/target/debug/debug: /home/nak/Code/rust/learn-rust/debug/src/main.rs
|
||||
BIN
1-hello-world/debug/target/debug/deps/debug-5a1b483393417d95
Executable file
BIN
1-hello-world/debug/target/debug/deps/debug-5a1b483393417d95
Executable file
Binary file not shown.
@ -0,0 +1,5 @@
|
||||
/home/nak/Code/rust/learn-rust/debug/target/debug/deps/debug-5a1b483393417d95.d: src/main.rs
|
||||
|
||||
/home/nak/Code/rust/learn-rust/debug/target/debug/deps/debug-5a1b483393417d95: src/main.rs
|
||||
|
||||
src/main.rs:
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user