MCPcopy Index your code
hub / github.com/corrode/refactoring-rust

github.com/corrode/refactoring-rust @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
326 symbols 435 edges 54 files 31 documented · 10%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Refactoring Rust

Hands-on exercises for writing more idiomatic, maintainable Rust.

Sample exercise

With Rustlings and 100 exercises to learn Rust, there exist two excellent resources for learning Rust.

What I found to be lacking was a more advanced course, which teaches Rust idioms and patterns by means of refactoring exercises, for typical real-world scenarios.

That's what "Refactoring Rust" is all about.

Each exercise asks you to take a small, working-but-awkward piece of code and make it more idiomatic. There is typically more than one good answer. The goal is not to be a definitive source of truth, but rather to give us something concrete to talk about.

Running an exercise

cargo run --example 01_starts_with_uppercase
cargo test --example 01_starts_with_uppercase

Overview

The examples are numbered roughly by complexity. We'll start with quick warm-ups everyone can finish in a few minutes and gradually move into larger structural refactors. Feel free to skip around: each example is self-contained.

Extension points exported contracts — how you extend this code

FunStr (Interface)
A bunch of little string helpers, exposed as an extension trait on `str`. Solution highlights: - An extension trait let [1 …
solutions/21_fun_strings_ext.rs

Core symbols most depended-on inside this repo

parse
called by 10
solutions/26_env_file_parser.rs
parse
called by 9
solutions/27_mini_redis.rs
commit
called by 7
solutions/26_env_file_parser.rs
parse_env
called by 6
solutions/26_env_file_parser.rs
parse
called by 5
examples/26_env_file_parser.rs
handle
called by 4
solutions/27_mini_redis.rs
next
called by 4
solutions/19_iterators.rs
handle
called by 4
examples/27_mini_redis.rs

Shape

Function 290
Enum 14
Method 12
Class 9
Interface 1

Languages

Rust100%

Modules by API surface

solutions/26_env_file_parser.rs21 symbols
solutions/27_mini_redis.rs17 symbols
solutions/14_room_occupancy.rs10 symbols
examples/14_room_occupancy.rs10 symbols
solutions/24_http_response_router.rs9 symbols
solutions/25_config_loader.rs8 symbols
solutions/21_fun_strings_ext.rs8 symbols
examples/27_mini_redis.rs8 symbols
examples/25_config_loader.rs8 symbols
solutions/10_parse_port.rs7 symbols
examples/26_env_file_parser.rs7 symbols
examples/24_http_response_router.rs7 symbols

For agents

$ claude mcp add refactoring-rust \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact