feat: lib + concepts
This commit is contained in:
1 parent
2318258718
commit
0962166a06
5 files changed
+30
-2
No files matched your search
@@ -0,0 +1,14 @@
|
||||
fn box_integer(number: i32) -> Box<i32> {
|
||||
Box::new(number)
|
||||
}
|
||||
|
||||
fn box_function() -> Box<fn(i32) -> Box<i32>> {
|
||||
Box::new(box_integer)
|
||||
}
|
||||
|
||||
pub fn box_basics() {
|
||||
let boxed_int = box_integer(3);
|
||||
let boxed_boxer = box_function();
|
||||
let another_boxed_int = boxed_boxer(4);
|
||||
print!("Box basics: {} {}", boxed_int, another_boxed_int);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
mod box_basics;
|
||||
|
||||
pub use box_basics::box_basics;
|
||||
Binary file not shown.
+5
-2
@@ -14,8 +14,9 @@
|
||||
// mod controlflow;
|
||||
// mod traits;
|
||||
// mod str_types;
|
||||
mod functions;
|
||||
// mod functions;
|
||||
// mod exercises;
|
||||
mod concepts;
|
||||
|
||||
fn main() {
|
||||
// helloworld::hello_world_module();
|
||||
@@ -27,6 +28,8 @@ fn main() {
|
||||
// controlflow::control_flow_module();
|
||||
//traits::traits_exercise();
|
||||
// str_types::str_types_module();
|
||||
functions::functions_module();
|
||||
// exercises::run_easy();
|
||||
// my_lib::public_function();
|
||||
// functions::functions_module();
|
||||
concepts::box_basics();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
pub fn public_function() {
|
||||
println!("This is a public funcion that calls a private one!");
|
||||
private_function();
|
||||
}
|
||||
|
||||
fn private_function() {
|
||||
println!("This is a private function!");
|
||||
}
|
||||
Reference in new issue
Block a user