Skip to content
Merged
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ check_formatting: fmt

cargo_test:
@echo "++ Run cargo $(OUR_CARGO_FLAGS) test on both crates"
( cd patchparser && cargo $(OUR_CARGO_FLAGS) test )
( cd patchparser && cargo $(OUR_CARGO_FLAGS) test --examples )
( cd split-patch && cargo $(OUR_CARGO_FLAGS) test )

cargo_check:
( cd patchparser && cargo $(OUR_CARGO_FLAGS) test --color=always )
( cd patchparser && cargo $(OUR_CARGO_FLAGS) build --examples --color=always )
( cd split-patch && cargo $(OUR_CARGO_FLAGS) test --color=always )
( cd patchparser && cargo $(OUR_CARGO_FLAGS) test --color=always)
( cd patchparser && cargo $(OUR_CARGO_FLAGS) test --examples --color=always )
( cd split-patch && cargo $(OUR_CARGO_FLAGS) test --color=always)

# This target is to abstract running clippy on everything (and can be run manually)
clippy:
Expand Down
4 changes: 2 additions & 2 deletions patchparser/examples/generate_patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn main() -> Result<()> {
similarity_line: None,
rename_from_line: None,
rename_to_line: None,
differences: Some(DiffDifferences {
differences: Some(&DiffDifferences {
index_line: Some("index line".into()),
minus_line: "minus line".into(),
plus_line: "plus line".into(),
Expand All @@ -77,7 +77,7 @@ fn main() -> Result<()> {
}),
remaining_lines: &["Hey there!".into(), "".into()],
},
diffs: bump.alloc([diff]),
diffs: &[&diff],
footer: &[],
};

Expand Down
320 changes: 0 additions & 320 deletions patchparser/src/bumpalo_cow.rs

This file was deleted.

28 changes: 28 additions & 0 deletions patchparser/src/coerce_ref.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pub trait CoerceRef {
type U;
fn coerce_ref(self) -> Self::U;
}

impl<'t, T, E> CoerceRef for Result<&'t mut T, E> {
type U = Result<&'t T, E>;

fn coerce_ref(self) -> Self::U {
self.map(|v| -> &T { v })
}
}

impl<'t, T, const N: usize> CoerceRef for [&'t mut T; N] {
type U = [&'t T; N];

fn coerce_ref(self) -> Self::U {
self.map(|v| -> &T { v })
}
}

impl<'t, T> CoerceRef for &'t mut T {
type U = &'t T;

fn coerce_ref(self) -> Self::U {
self
}
}
3 changes: 1 addition & 2 deletions patchparser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
pub mod anyhow_once;
pub mod bumpalo_bstring;
pub mod bumpalo_cow;
pub mod bumpalo_utils;
pub mod coerce_ref;
pub mod format_binary;
pub mod from_lines;
pub mod line;
pub mod patch;
pub mod reborrow_in;
pub mod regex_utils;
pub mod utils;
pub mod write_to;
Loading
Loading