A library packages reusable software behind an API that other programs can call. Good libraries aim to be easy to use, difficult to misuse, correct, focused, and maintainable. section 6.0 section 6.12
Design a library by balancing:
- User expectations and interface simplicity against unnecessary configuration or exposed surface area. section 6.1
- Feature completeness, delivery speed, and implementation quality. section 6.1
- Focused responsibilities, basic types, correctness checks, readable code, and backward compatibility. section 6.12
Publishing a linked-list library
Create a crate with `cargo new --lib linkedlist`, move the linked-list implementation into `src/lib.rs`, and test it from `tests/integration_test.rs`. External tests initially expose private types and methods; adding `pub` to the public structure, methods, and iterator types makes the crate usable while keeping fields private. section 6.11.1
#[test]
fn test_linkedlist() {
use linkedlist::LinkedList;
let mut linked_list = LinkedList::new("first item"); #1
// ... snip ...
}
Shows an integration test importing and constructing the public `LinkedList` type from outside the crate. section 6.11.1

