Please adhere to the following conventions and best practices when writing or modifying Rust code in this repository:
mod statementsuse statements#[cfg(test)].collect() over manually iterating and adding/pushing to data structures when possible._ (e.g. _var) should only be used if they are truly never used. If you begin using a variable that was prefixed with an underscore, rename it to remove the underscore prefix.unsafe blocks must be prefixed with a // Safety: <reason> comment explaining why the usage is safe.#[cfg(test)].///).extern "C" blocks or raw FFI calls) are allowed outside of the ffi submodule. The only exception is intern_string.thread_local! structures. They hinder concurrency, unit testing isolation, and multi-session safety. Always prefer passing state and context explicitly via arguments or trait objects.dyn Trait) in the hot path (any code that could be called an arbitrary number of times by a starlark rule).dyn Trait) in general if you can, but you may use it to increase testability of code if it is not in the hot path.dyn Trait to support a “real” version in production code and a fake one in test code.collect_repr and collect_strDebug is available on a type. It should just write!(collector, "{:?}").unwrap()Display is available on a type. It should just write!(collector, "{}").unwrap()thiserror for crate-level errors, rather than generic strings or custom hand-written Display implementations. Let exceptions and failures bubble up naturally.pub(crate) by default to maintain clean boundaries. Only use pub for APIs that are intended to be consumed by other crates.#pragma once - use header guards instead.