Hacker
Public
Radio
Your ideas, projects, opinions - podcasted.
New episodes Monday through Friday.
Hosted by
BlacKernel
on 2021-10-27 00:00:00
Talking Points
- main.rs
- Like main.cpp in C++ or main.c in C
- Tells the compiler which file to start with
- Can link to other "crates" and "modules"
- Cargo.toml
- Keeps track of application metadata
- This includes dependencies!
- Functions
- Strictly typed, like everything in Rust
- Declared by
fn
- Argument typed with
argument: Type
- Return typed with
-> Type
otherwise assumed to return nothing
- The Main Function
- Like the main functions in C and C++
- Where the program starts within the main.rs file
- CLI arguments handled by
std::env
, rather than argv
and argc
in C
- Can return nothing or a
Result<()>
- Macros
- Metafunctions or functions for functions
- More general than functions, having flexibility in the number of arguments, etc, but harder to write
- The println! Macro
- Can take any number of arguments that implement the
display
trait
- Usually things like strings or character literals
- Will format them into a string and display it on the terminal
- Similar to printf in C
- The Hello World program
- Can be automagically generated with
cargo new
and then the name of your application
- Located in
Name-Of-Application/src/main.rs
fn main() {
println!("Hello, world!");
}
Show Notes
Important Links:
Wikipedia Articles:
Contact Me
More Information...
Copyright Information
Unless otherwise stated, our shows are released under a Creative Commons
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.
The HPR Website Design is released to the Public Domain.