<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy" -->

---
title: 3 way to structure your Rust projects | daily.dev
description: A walkthrough of three progressively more complex ways to organize a Rust project, illustrated by building a small static site generator. It starts with...
canonical: https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: 3 way to structure your Rust projects | daily.dev
og:description: A walkthrough of three progressively more complex ways to organize a Rust project, illustrated by building a small static site generator. It starts with...
og:url: https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy
og:image: https://api.daily.dev/og/posts/LOHHeIFqy.png
og:image:alt: 3 way to structure your Rust projects
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 3 way to structure your Rust projects

**[Let's Get Rusty](https://daily.dev/sources/letsgetrusty)** · 4 min read · 2 upvotes · 1 comments

## Summary

A walkthrough of three progressively more complex ways to organize a Rust project, illustrated by building a small static site generator. It starts with everything in a single main.rs file, then splits logic into modules across files, then extracts a reusable library crate so the build logic can be shared between a CLI binary, a dev server binary, and integration tests, and finally moves to a Cargo workspace to isolate dependencies (e.g., keeping Axum out of the CLI build). The guidance: start with one file, add modules when it gets unwieldy, extract a library when you need to reuse or test logic, and use a workspace only when components are genuinely separate or compile times suffer. Ends with a promotion for a paid Rust mentorship program.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=mkW3dTxBmm0>

## Questions this post answers

### When should I split a Rust project into a Cargo workspace instead of just using a library crate?

Use a workspace only when you have genuinely separate components or when compile times start to hurt. A single package with one library crate and multiple binaries shares one dependency list, so a CLI tool ends up compiling unrelated dependencies like Axum even if it never uses them; splitting into a workspace with separate packages (e.g., core, CLI, serve) isolates dependencies so each binary only builds what it actually needs.

_daily.dev surfaces practical Rust architecture guidance for developers deciding when workspaces are worth the overhead._

### How do I share build logic between a Rust binary and integration tests?

Extract the logic into a public function inside a library crate (lib.rs) rather than keeping it in main.rs, since external code, including integration tests and other binaries, cannot access code inside a binary crate's main.rs. Marking the function pub lets main.rs, integration tests, and additional binaries all import and call it directly.

_Developers restructuring Rust code for testability can track patterns like this one on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@pdfopsdev** · 0 upvotes

> I'd push the workspace split earlier than 'components are genuinely separate' suggests. pull binary-only deps like axum out the moment you notice cli build times creeping, waiting for it to feel obviously separate usually means you already ate weeks of slow incremental builds.

## Similar posts on daily.dev

- [Guideline: Rust Style](https://daily.dev/posts/guideline-rust-style-rxs5ftv9c) · Lobsters · 4 upvotes · 0 comments
- [Medium](https://daily.dev/posts/medium-j5k11rvds) · Medium · 0 upvotes · 0 comments
- [How to make your own static site generator](https://daily.dev/posts/how-to-make-your-own-static-site-generator-jfrbheb6t) · Lobsters · 1 upvotes · 0 comments

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#rust](https://daily.dev/tags/rust)

[View this post on daily.dev](https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"3 way to structure your Rust projects","url":"https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy"},"datePublished":"2026-09-28T16:44:35.290Z","dateModified":"2026-09-28T16:44:52.272Z","description":"A walkthrough of three progressively more complex ways to organize a Rust project, illustrated by building a small static site generator. It starts with...","image":"https://i.ytimg.com/vi/mkW3dTxBmm0/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/mkW3dTxBmm0/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Let's Get Rusty","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Let's Get Rusty","logo":"https://media.daily.dev/image/upload/s--iqd05ejH--/f_auto/v1725035314/logos/letsgetrusty","url":"https://daily.dev/sources/letsgetrusty"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"architecture,rust","timeRequired":"PT4M","video":{"@type":"VideoObject","name":"3 way to structure your Rust projects","description":"A walkthrough of three progressively more complex ways to organize a Rust project, illustrated by building a small static site generator. It starts with...","thumbnailUrl":"https://i.ytimg.com/vi/mkW3dTxBmm0/sddefault.jpg","uploadDate":"2026-09-28T16:44:35.290Z","duration":"PT4M","url":"https://api.daily.dev/r/LOHHeIFqy","embedUrl":"https://www.youtube.com/embed/mkW3dTxBmm0"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Let's Get Rusty","item":"https://daily.dev/sources/letsgetrusty"},{"@type":"ListItem","position":3,"name":"3 way to structure your Rust projects"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy","comment":[{"@type":"Comment","text":"I’d push the workspace split earlier than ‘components are genuinely separate’ suggests. pull binary-only deps like axum out the moment you notice cli build times creeping, waiting for it to feel obviously separate usually means you already ate weeks of slow incremental builds.","datePublished":"2026-09-29T18:17:56.803Z","url":"https://daily.dev/posts/LOHHeIFqy#c-L8EXHZynP","author":{"@type":"Person","name":"PDFops","url":"https://daily.dev/pdfopsdev","image":"https://media.daily.dev/image/upload/s---8isRBKc--/f_auto/v1782922291/avatars/avatar_orjMeK8QKaaVZwGq7ScPz?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/3-way-to-structure-your-rust-projects-lohheifqy#faq","mainEntity":[{"@type":"Question","name":"When should I split a Rust project into a Cargo workspace instead of just using a library crate?","acceptedAnswer":{"@type":"Answer","text":"Use a workspace only when you have genuinely separate components or when compile times start to hurt. A single package with one library crate and multiple binaries shares one dependency list, so a CLI tool ends up compiling unrelated dependencies like Axum even if it never uses them; splitting into a workspace with separate packages (e.g., core, CLI, serve) isolates dependencies so each binary only builds what it actually needs. daily.dev surfaces practical Rust architecture guidance for developers deciding when workspaces are worth the overhead."}},{"@type":"Question","name":"How do I share build logic between a Rust binary and integration tests?","acceptedAnswer":{"@type":"Answer","text":"Extract the logic into a public function inside a library crate (lib.rs) rather than keeping it in main.rs, since external code, including integration tests and other binaries, cannot access code inside a binary crate's main.rs. Marking the function pub lets main.rs, integration tests, and additional binaries all import and call it directly. Developers restructuring Rust code for testability can track patterns like this one on daily.dev."}}]}
```

