Naming
Create crates with kebab-case names (kebab-case-crate-names)
Asterinas prefers kebab-case for crate names, which is unspecified in official Rust API Guidelines.
// Good
[package]
name = "short-vis-path"
// Bad
[package]
name = "short_vis_path"
Follow Rust CamelCase and acronym capitalization (camel-case-acronyms)
Type names follow Rust’s CamelCase convention. Acronyms are title-cased per the Rust API Guidelines:
// Good
IoMemoryArea
PciDeviceLocation
Nvme
Tcp
// Bad
IOMemoryArea
PCIDeviceLocation
NVMe
TCP
End closure variables with _fn (closure-fn-suffix)
Variables holding closures or function pointers
must signal they are callable by ending with _fn.
Treating a closure variable
as if it were a data object misleads readers.
// Good — clearly a callable
let task_fn = self.func.take().unwrap();
let thread_fn = move || {
let _ = oops::catch_panics_as_oops(task_fn);
current_thread!().exit();
};
let expired_fn = move |_guard: TimerGuard| {
ticks.fetch_add(1, Ordering::Relaxed);
pollee.notify(IoEvents::IN);
};