mirror of
https://github.com/darkicewolf50/RustBrock.git
synced 2025-07-06 02:57:13 -06:00
finished ch3 started on ch4
This commit is contained in:
6
functions_rust/Cargo.toml
Normal file
6
functions_rust/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "functions_rust"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
15
functions_rust/src/main.rs
Normal file
15
functions_rust/src/main.rs
Normal file
@ -0,0 +1,15 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
example_function(1, 4); // can be delared before or after function that uses it
|
||||
}
|
||||
|
||||
// fn is the keyword for functions
|
||||
fn example_function (x:i8, y:u16) {
|
||||
// type must be delared cannot be inferred
|
||||
// name of parameter/argument is in the brakets seperated by commas
|
||||
// {} show scope of function
|
||||
|
||||
// can be used directly form pram delaration
|
||||
println!("Look anthoer Function {} {y}", x);
|
||||
|
||||
}
|
Reference in New Issue
Block a user