Eight small exercises, 37 tests, and one goal: make you comfortable with the Rust you need to read and write a Solana program.
This repository is public. You do not need an invitation, and you do not get write access to it. Fork it, solve the exercises in your fork, and open a pull request. The pull request is your submission; the instructor grades its checks.
The exercises match the two decks:
| Deck | Exercises | Tests |
|---|---|---|
| Rust Basics 1 | ex01 – ex04 | 19 |
| Rust Basics 2 | ex05 – ex08 | 18 |
| Total | ex01 – ex08 | 37 |
- Click Fork at the top of this page. This makes your own copy on GitHub.
- Clone your fork, not the class repository:
git clone https://github.com/<your-username>/Solana-Rust-Bootcamp-EN-.git
cd Solana-Rust-Bootcamp-EN-- Keep the class repository as
upstream, so you can pull updates later:
git remote add upstream https://github.com/dev3pack/Solana-Rust-Bootcamp-EN-.git- Run the tests:
cargo testThe first run compiles the crate and fails every test, because every function
ends in todo!(). That is expected. Pick one exercise, read its task, and make
its tests pass.
Create a branch in your fork. Do not work on main.
git checkout -b solutions/your-namemain stays as the starter. Your branch holds your answers. This also keeps
your work separate from everyone else's.
Run one exercise at a time while you work:
cargo test --test ex01Run everything before you push:
cargo testPush to your fork:
git add .
git commit -m "ex01-ex08 solutions"
git push -u origin solutions/your-nameYou will see unused variable warnings from the starter functions. They
disappear as you replace each todo!() with a real implementation.
After you push your branch, open a pull request:
- Go to your fork on GitHub.
- Click Contribute → Open pull request.
- Base repository:
dev3pack/Solana-Rust-Bootcamp-EN-. - Base branch:
main. - Head repository: your fork.
- Compare branch:
solutions/your-name. - Title:
Solutions — your name. - Click Create pull request.
Do not merge the pull request. It is a submission, not a change to the class repo. The instructor grades the checks and then closes it.
Your fork is public, like this repository. Do not put passwords, private keys, or personal data in it.
src/
lib.rs the crate root; declares the eight modules
ex01.rs variables and types
ex02.rs functions and control flow
ex03.rs ownership
ex04.rs borrowing
ex05.rs structs and impl
ex06.rs enums and match
ex07.rs Result and ?
ex08.rs capstone: mini bank
tests/
ex01.rs ... ex08.rs the 37 tests; do not edit
tasks/
ex01.md ... ex08.md what to build in each exercise
.github/workflows/tests.yml
tests.sha256 checksums used by CI to detect edited tests
AI_POLICY.md
- Read
tasks/exNN.md. - Open
src/exNN.rs. - Replace one
todo!()at a time. - Run
cargo test --test exNN. - Read the compiler error from top to bottom: error code, arrow, help.
- When the exercise is green, move to the next one.
- When all 37 tests pass, push your branch and open the pull request.
The tests are the specification. If a test and a task description disagree, the test wins. If you believe a test is wrong, ask the instructor; do not edit it.
- Keep your changes in
src/. Do not edittests/,tests.sha256, or.github/. - Do not edit anything in
tests/. CI runssha256sum -c tests.sha256before the tests. A changed test file fails the build even if the code passes. - Do not delete or rename tests. The grader counts passed tests out of 37.
- No
HashMapand no traits in ex08. The capstone uses aVec<String>for history on purpose. Keep it simple. - No panics for expected failures. Use
Resultin ex07 and ex08. Atodo!(),unwrap()on user input, orpanic!()is not error handling. - AI is allowed as a tutor, not as a solution machine. Read
AI_POLICY.md. If you cannot explain your code in a two-minute call, it does not count.
Each test is worth one point. The automatic grade is:
points = number of passing tests
Your part is graded out of the tests for that part: 19 for Rust Basics 1 and 18
for Rust Basics 2. A mentor also samples solutions for unneeded unwrap() and
clone() calls, and may ask you to explain a solution. Passing tests with code
you cannot explain is not a pass.
The grade comes from the checks on your pull request, not from a push directly to the class repository.
Every pull request to the class repo runs:
sha256sum -c tests.sha256— verifies that the test files are unchanged.cargo test --locked— runs all 37 tests.
Pushes to your fork may run the workflow too, if Actions are enabled there. The pull request run is the one that counts. If this is your first pull request, GitHub may ask the instructor to approve the workflow; that is normal.
CI is red at the start, because todo!() panics. It turns green when all 37
tests pass. To run the checksum yourself on macOS:
shasum -a 256 -c tests.sha256If the checksum step fails, restore the tests:
git checkout -- tests/Then run the tests again. If you added a test of your own, put it in a separate
file outside tests/ or remove it before opening the pull request; only the
official 37 tests count.
| Error | What it means | First thing to try |
|---|---|---|
E0382 |
You used a value after it moved | Borrow it with &, or clone it if you really need two owners |
E0502 |
A read and a write are alive at the same time | Finish the read before you write |
E0308 |
Mismatched types | Compare the function signature with the value you return |
E0004 |
A match is missing a case |
Add the missing arm, or use _ only when a catch-all is correct |
E0499 |
More than one mutable borrow | Keep one &mut alive at a time |
E0596 |
Cannot borrow as mutable | Declare the binding with let mut |
todo!() is not a compiler error. It compiles and panics at runtime with
"not yet implemented". If you see that panic, the function is still a stub.
- The Rust Book, chapters 3 to 9: https://doc.rust-lang.org/book/
- Rustlings, short drills: https://github.com/rust-lang/rustlings
- Rust standard library: https://doc.rust-lang.org/std/
- Solana docs: https://solana.com/docs
- Anchor docs: https://www.anchor-lang.com/docs
Open an issue in the class repository: https://github.com/dev3pack/Solana-Rust-Bootcamp-EN-/issues
Issues opened in your own fork are not seen by the instructor. Include the exercise number, the exact command you ran, and the full compiler error. Do not paste only the last line; the first line and the arrow matter.