feat: lib + concepts

This commit is contained in:
2025-01-20 08:44:08 +01:00
parent 2318258718
commit 0962166a06
5 changed files with 30 additions and 2 deletions

View File

@@ -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);
}

3
src/concepts/mod.rs Normal file
View File

@@ -0,0 +1,3 @@
mod box_basics;
pub use box_basics::box_basics;

BIN
src/lib/libmy_lib.rlib Normal file
View File

Binary file not shown.

View File

@@ -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();
}

8
src/my_lib.rs Normal file
View File

@@ -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!");
}