When behavior depends on platform features, build features, feature flags, or user-provided configuration, keep it explicitly scoped and validated.

Apply this checklist:

Example pattern (cfg + validated parsing):

// Build gating: don't compile unix-only code on Windows.
#[cfg(unix)]
mod local_api;

// Validation: enforce invariants at parse time.
fn parse_positive_usize_query_param(url: &Url, name: &str) -> Result<Option<usize>> {
    let Some(raw) = url.query_pairs().find(|(k, _)| k == name).map(|(_, v)| v) else {
        return Ok(None);
    };
    let value = raw.parse::<usize>()?;
    ensure!(value > 0, "`{name}` must be greater than 0");
    Ok(Some(value))
}

These practices prevent cross-platform build breaks, mis-scoped feature behavior, and silent misconfiguration—while keeping configuration-driven behavior predictable and maintainable.