Special Syntax Rules
§13 F-String
§13.1 F-String Format. F-String uses the f"..." format, with interpolation using {expr}.
// ✅ Correct
let msg = f"Hello, {name}!";
let msg = f"Result: {x + y}";§13.2 Formatting Specifications. F-String supports formatting specifications {expr:spec}.
// ✅ Correct
let msg = f"{value:.2f}";§14 Import Statements
§14.1 Import Sorting. When sort_imports = true, import statements are sorted in the following order:
- Standard library (
std,core,alloc) - External crates
- Relative paths (starting with
.or..)
§14.2 In-group Sorting. Imports within the same group are sorted alphabetically.
// Before sorting
use z_crate;
use std::collections;
use a_crate;
use ./local;
// After sorting
use std::collections;
use a_crate;
use z_crate;
use ./local;§17 Error Handling
§17.1 Try Operator. Use the expr? format.
// ✅ Correct
let x = foo()?;
// ❌ Incorrect
let x = foo() ?;§18 Unsafe Block
§18.1 Unsafe Format. Use the unsafe { ... } format.
// ✅ Correct
let x = unsafe { dangerous_function() };
// ❌ Incorrect
let x = unsafe{ dangerous_function() };