Where to put code not directly related to the project?

⚓ Rust    📅 2025-11-28    👤 surdeus    👁️ 5      

surdeus

I'd like to save code pieces I write for testing libraries, or ideas, or for documentation. This code is going to be linked in ADRs, or commit messages, or in task tracker. It's not directly related to the project, it's only illustrative.

So, the question is: where to put this code? I could use the examples/ folder, but it's unclear if it is reserved for examples on how to use a library, when I publish one.

I could create a single crate for these pieces of code, I could create multiple crates, I could create a doc/examples/ directory and do cargo new in it for every code piece. I also could use rust-script to have self-contained single source files.

What option would an experienced rust developer choose?

I understand this is probably bikeshedding, but I'd like to maintain order in my project.

4 posts - 2 participants

Read full topic

🏷️ Rust_feed