patch_rs/patch.rs
1//!
2//! The Patch structure.
3//!
4
5use std::{
6 fmt,
7 collections::VecDeque,
8};
9
10use crate::context::Context;
11
12#[derive(Default)]
13pub struct Patch {
14 pub input: String,
15 pub output: String,
16 pub contexts: VecDeque<Context>,
17}
18
19impl fmt::Display for Patch {
20 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21 writeln!(f, "--- {}", self.input)?;
22 writeln!(f, "+++ {}", self.output)?;
23 for context in self.contexts.iter() {
24 write!(f, "{}", context)?;
25 }
26 Ok(())
27 }
28}