From ce0dcefe6d8cdf439af164b5e19f49f56b472d22 Mon Sep 17 00:00:00 2001 From: Shikong <919411476@qq.com> Date: Sun, 26 Jun 2022 15:01:16 +0800 Subject: [PATCH] hello_world 1~2 --- .gitignore | 9 +++++---- 1.hello_world/main.rs | 7 +++++++ 2.hello_cargo/Cargo.toml | 8 ++++++++ 2.hello_cargo/src/main.rs | 6 ++++++ 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 1.hello_world/main.rs create mode 100644 2.hello_cargo/Cargo.toml create mode 100644 2.hello_cargo/src/main.rs diff --git a/.gitignore b/.gitignore index 4a0ec41..ad9d8ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,13 @@ ### Rust template # Generated by Cargo # will have compiled files and executables -debug/ -target/ - +**/debug/ +**/target/ +**/*.exe +**/*.pdb # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock +**/Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk diff --git a/1.hello_world/main.rs b/1.hello_world/main.rs new file mode 100644 index 0000000..63c90d9 --- /dev/null +++ b/1.hello_world/main.rs @@ -0,0 +1,7 @@ +// 编译 +// rustc ./main.rs + +// 主函数入口 +fn main() { + println!("Hello World"); +} diff --git a/2.hello_cargo/Cargo.toml b/2.hello_cargo/Cargo.toml new file mode 100644 index 0000000..19c7b36 --- /dev/null +++ b/2.hello_cargo/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "hello_cargo" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/2.hello_cargo/src/main.rs b/2.hello_cargo/src/main.rs new file mode 100644 index 0000000..df3a1fe --- /dev/null +++ b/2.hello_cargo/src/main.rs @@ -0,0 +1,6 @@ +// Cargo 创建项目 +// cargo new hello_cargo + +fn main() { + println!("Hello, world!"); +}