organizing_files
This commit is contained in:
parent
f0fe3ae8bd
commit
b57a5a71f5
7 changed files with 42 additions and 0 deletions
8
19-organizing_files/Cargo.toml
Normal file
8
19-organizing_files/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "organizing_files"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
2
19-organizing_files/src/lake.rs
Normal file
2
19-organizing_files/src/lake.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
//We export duck module to use in another scope.
|
||||
pub mod duck;
|
3
19-organizing_files/src/lake/duck.rs
Normal file
3
19-organizing_files/src/lake/duck.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub fn hi_from_duck() {
|
||||
println!("I'm duck");
|
||||
}
|
3
19-organizing_files/src/lib.rs
Normal file
3
19-organizing_files/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
//We export gift_first and gift_second modules to use in another scope.
|
||||
pub mod lake;
|
||||
pub mod plain;
|
21
19-organizing_files/src/main.rs
Normal file
21
19-organizing_files/src/main.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
//We can call modules with use to bring them into scope
|
||||
|
||||
//Call them seperately
|
||||
//use organizing_files::gift_first;
|
||||
//use organizing_files::gift_second;
|
||||
|
||||
//Call them together
|
||||
use organizing_files::{lake, plain};
|
||||
|
||||
//Call every export with "glob"
|
||||
//use organizing_files::*;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
|
||||
//Call duck from lake scope
|
||||
lake::duck::hi_from_duck();
|
||||
|
||||
//Call bunny from plain scope
|
||||
plain::bunny::hi_from_bunny();
|
||||
}
|
2
19-organizing_files/src/plain.rs
Normal file
2
19-organizing_files/src/plain.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
//We export bunny module to use in another scope.
|
||||
pub mod bunny;
|
3
19-organizing_files/src/plain/bunny.rs
Normal file
3
19-organizing_files/src/plain/bunny.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub fn hi_from_bunny() {
|
||||
println!("I'm bunny");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue