feat: lib + concepts
This commit is contained in:
14
src/concepts/box_basics.rs
Normal file
14
src/concepts/box_basics.rs
Normal 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
3
src/concepts/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
mod box_basics;
|
||||
|
||||
pub use box_basics::box_basics;
|
||||
BIN
src/lib/libmy_lib.rlib
Normal file
BIN
src/lib/libmy_lib.rlib
Normal file
Binary file not shown.
@@ -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
8
src/my_lib.rs
Normal 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!");
|
||||
}
|
||||
Reference in New Issue
Block a user