ocpi-tariffs 0.55.0

OCPI tariff calculations
Documentation
//! Test support for proposing fixes.

use super::{Edit, Error, Fixable, Proposed, proposed_edits, refuse_clashing_renames};
use crate::{json, warning};

/// The edits that resolve `warnings`, in document order, with every clashing rename
/// refused. `lint::fix` does the same for one set of warnings in each pass, so the fix tests call
/// this rather than joining a schema set and a lint set.
///
/// A rename clashes in three cases, and `refuse_clashing_renames` drops it in each:
///
/// - Another rename writes the same key in the same object.
/// - The object still holds a field with that key once the other edits are applied.
/// - Another fix renames the same field.
pub(super) fn edits<W: Fixable>(
    doc: &json::Document<'_>,
    warnings: &warning::Set<W>,
) -> Result<Vec<Edit>, Error> {
    let mut proposed = proposed_edits(doc, warnings)?;
    let _refused = refuse_clashing_renames(doc, &mut proposed);
    let edits = proposed.into_iter().map(Proposed::into_edit).collect();

    Ok(edits)
}