From 84ad9939ae33d8172512e11ecdc228433ea14130 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 17 Sep 2024 09:13:46 +0000 Subject: [PATCH 1/2] Add some more docs --- README.md | 4 ++++ src/lib.rs | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 907ffaa..3810475 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ Given BASE, OTHER, THIS, tries to produce a combined text incorporating the changes from both BASE->OTHER and BASE->THIS. All three will typically be sequences of lines. +The implementation is primarily meant to be used with text files, but +it should work with any type that can be represented as a sequence of +lines. + Usage ===== diff --git a/src/lib.rs b/src/lib.rs index f92dced..c25e845 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,6 +5,9 @@ //! incorporating the changes from both BASE->OTHER and BASE->THIS. //! All three will typically be sequences of lines. //! +//! While the primary use case is for text, the implementation is generic and can be used with any +//! type that implements Eq and Hash. +//! //! ## Example //! //! ```rust @@ -58,7 +61,6 @@ fn compare_range( /// Given BASE, OTHER, THIS, tries to produce a combined text incorporating the changes from both /// BASE->OTHER and BASE->THIS. All three will typically be sequences of lines, but don't have to /// be. - pub struct Merge3<'b, T: Eq + std::hash::Hash + ?Sized> { // Lines in BASE base: &'b [&'b T], @@ -609,6 +611,11 @@ pub enum MergeGroup<'a, T: Eq> { Conflict(Option<&'a [T]>, &'a [T], &'a [T]), } +/// Markers for a merge. +/// +/// These are used to provide context for a merge conflict. +/// The markers are inserted into the merged text to show where the conflicts are. +/// The markers are typically used to show the start and end of a conflict region. pub trait LineMarkers<'a, T: ToOwned + ?Sized> { fn start_marker(&self) -> Option>; fn base_marker(&self) -> Option>; @@ -684,6 +691,7 @@ impl<'a> LineMarkers<'a, [u8]> for StandardMarkers<'a> { } } +/// Custom markers for 3-way merge. #[derive(Default)] pub struct CustomMarkers<'a> { pub start_marker: Option<&'a str>, From d9e4e2f1282df4a6d33d852bf34920298ef4c34b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 24 Sep 2024 14:40:55 +0000 Subject: [PATCH 2/2] Check formatting in CI --- .github/workflows/rust.yml | 6 ++++++ .gitignore | 1 + 2 files changed, 7 insertions(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 823a3dc..d55385d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -16,5 +16,11 @@ jobs: - uses: actions/checkout@v4 - name: Build run: cargo build --verbose + env: + RUSTFLAGS: -Dwarnings - name: Run tests run: cargo test --verbose + env: + RUSTFLAGS: -Dwarnings + - name: Check formatting + run: cargo fmt -- --check diff --git a/.gitignore b/.gitignore index ea8c4bf..e2a3069 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +*~