Sling Academy
Home/Rust/Packages, Crates, and Modules in Rust

Packages, Crates, and Modules in Rust

Rust organizes code into **packages** (projects with `Cargo.toml`), **crates** (compilable units, binary or library), and **modules** (organize code within crates). Packages manage dependencies, crates provide functionality, and modules ensure structure and scope, promoting reusable and maintainable Rust projects.

1 Understanding the Distinctions Among Packages, Crates, and Modules in Rust

2 Creating a Minimal Rust Project with Cargo and Default Package Structure

3 Defining a Library Crate vs a Binary Crate in Rust

4 Rust - Exploring the Cargo.toml File: Dependencies, Versions, and Features

5 Organizing Code with Modules: The mod Keyword in Rust

6 Using submodules to Split Large Rust Files into Manageable Components

7 Navigating Visibility: pub vs Private Items in Rust Modules

8 Understanding Cargo Workspaces for Multi-Crate Projects in Rust

9 Re-exports and Namespacing Strategies with use in Rust Modules

10 Rust - Building and Publishing a Rust Crate to crates.io

11 Adding External Crates to Your Rust Package with Cargo Dependencies

12 Overriding Dependency Versions in Rust Cargo Projects

13 Using dev-dependencies for Testing and Benchmarking in Rust

14 Developing Monorepos with Cargo Workspaces in Rust

15 Taming Large Codebases: Layering Modules and submodules in Rust

16 Splitting Code into Separate Files for Clarity in Rust Modules

17 Creating Custom Paths in Rust with Cargo’s [workspace] Configuration

18 Handling Feature Flags to Toggle Functionality in Rust Crates

19 Private Modules: Encapsulation and API Boundaries in Rust

20 Using #[path] Attributes to Rename or Relocate Rust Modules

21 Combining Rust’s Module System with Namespaced Enums and Structs

22 Rust - Introducing Macros Within the Same Crate: mod macros vs Macro Crates

23 Publishing Versions and Changelogs for Rust Crates on crates.io

24 Pre-release Versions and SemVer Considerations in Rust Packages

25 Rust - Working with Git Dependencies in Cargo for Experimental Crates

26 Overcoming Cyclic Dependencies by Refactoring Rust Modules

27 Exporting Types and Functions in Rust via Re-exporting Modules

28 Testing in Rust: Using Integration Tests in a Separate Tests Folder

29 Running Examples and Benchmarks with Cargo for Rust Projects

30 Leveraging the Cargo.lock File for Repeatable Builds in Rust

31 Rust - Pinning Dependencies to Specific Git Revisions in Cargo

32 Conditional Compilation with Cargo Features in Rust Crates

33 Handling Platform-Specific Code with cfg Attributes in Rust Modules

34 Splitting Shared Logic Between Binary and Library Crates in Rust

35 Refactoring to Library + Binary Crates for Reusability in Rust

36 Implementing Custom Build Scripts (build.rs) in Rust Packages

37 Rust - Understanding the cargo publish Workflow and crate Ownership

38 Configuring Documentation Generation with cargo doc in Rust

39 Rust - Optimizing Build Times with cargo check for Rapid Development

40 Using cargo fmt and cargo clippy to Maintain Consistent Rust Code

41 Rust - Documenting Modules and Crates with Rustdoc Comments

42 Rust - Managing Version Conflicts Across Multiple Crates in a Workspace

43 Applying #[macro_use] and #[macro_export] for Macro Crates in Rust

44 Handling Repetitive Patterns with Submodules and Public APIs in Rust

45 Stabilizing APIs and Avoiding Breaking Changes in Published Rust Crates

46 Migrating From Single-File Projects to Modular Structures in Rust

47 Rust - Utilizing Private Crates in Company-Internal Registries

48 Exploring Cargo Plugins and Extension Commands for Rust Projects

49 Best Practices for Structuring Large-Scale Rust Applications with Modules