Library
Let’s create a library, and then see how to link it to another crate.
1. pub fn public_function() {
2. println!("called rary's `public_function()`");
3. }
5. fn private_function() {
6. println!("called rary's `private_function()`");
7. }
9. pub fn indirect_access() {
10. print!("called rary's `indirect_access()`, that\n> ");
12. private_function();
13. }
1. $ rustc --crate-type=lib rary.rs
2. $ ls lib*
3. library.rlib
Libraries get prefixed with “lib”, and by default they get named after their
crate file, but this default name can be overridden using the crate_name
attribute.
