| Crates.io | shafu-rs |
| lib.rs | shafu-rs |
| version | 0.1.0 |
| created_at | 2025-07-27 13:35:20.521257+00 |
| updated_at | 2025-07-27 13:35:20.521257+00 |
| description | Solidity formatter in style of @shafu0x |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1770073 |
| size | 58,788 |
A fast Solidity code formatter written in Rust that applies the "shafu" style formatting rules.
# Clone and build
git clone <repository>
cd shafu-rs
cargo build --release
# The binary will be available at target/release/shafu
cargo install --path .
# Format a file and print to stdout
shafu path/to/your/file.sol
# Format a file and write changes back
shafu path/to/your/file.sol --write
Before formatting:
contract Example {
uint256 public balance;
address public owner;
function transfer(address to, uint256 amount, bytes memory data) external {
require(balance >= amount, "Insufficient balance");
require(to != address(0), "Invalid address");
}
}
After formatting:
contract Example {
uint public balance;
address public owner;
function transfer(
address to,
uint amount,
bytes memory data
)
external
{
require(balance >= amount, "Insufficient balance");
require(to != address(0), "Invalid address");
}
}
shafu-rs/
├── src/
│ ├── main.rs # CLI interface
│ ├── lib.rs # Main library entry point
│ └── formatter.rs # Core formatting logic
├── Cargo.toml
└── README.md
# Run tests
cargo test
# Test against example files
cargo run -- ../shafu-formatter/tests/0_before/00_simple_storage_vars.sol
# Debug build
cargo build
# Release build
cargo build --release
# Run directly
cargo run -- <file.sol> [--write]
The Rust version maintains functional parity with the Python version while offering:
[License information here]