code_passenger 0.4.7

Scans a Rust workspace with klepto and does the writing: feature gates across every crate from one features document, proven by cargo check, Cargo.toml edits, file headers from the plan, and the history of it.
Documentation
use crate::model::{FileReport, PlanSection};
use super::{HeaderPlan, HeaderPlanV2};


pub struct CompactPlan;

impl HeaderPlan for CompactPlan {
    fn id(&self) -> &'static str { "compact" }

    fn render_for_rust(&self, report: &FileReport, begin: &str, end: &str) -> String {
        let mut out = String::new();
        out.push_str(begin);
        out.push('\n');

        out.push_str(&format!("//! file: {}\n", report.document.relative_path));
        out.push_str(&format!("//! used_deps: {:?}\n", report.used.packages));
        out.push_str("//!\n");
        for f in &report.corpus_features {
            out.push_str(&format!("#![cfg(feature = \"{}\")]\n", f));
        }

        out.push_str(end);
        out.push('\n');
        out
    }
}

impl HeaderPlanV2 for CompactPlan {
    fn id(&self) -> &'static str { "compact" }

    fn sections(&self) -> &[PlanSection] {
        const SECTIONS: &[PlanSection] = &[
            PlanSection::DocumentDetails,
            PlanSection::CorpusGates,
        ];
        SECTIONS
    }
}