🏡 index : ~doyle/packfile.git

author Jordan Doyle <jordan@doyle.la> 2023-07-04 20:36:18.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2023-07-04 20:38:14.0 +00:00:00
commit
9761faba8dc17e270073c3ea8bf2f33763cfd580 [patch]
tree
9a4c2fe016c652e3022afa9e2ca53996f79c9e47
parent
4caaf60a7e74100bacf10953da312afb71e3d239
download
9761faba8dc17e270073c3ea8bf2f33763cfd580.tar.gz

Collect code coverage



Diff

 .github/workflows/coverage.yml | 26 ++++++++++++++++++++++++++
 src/util.rs                    | 10 +++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
new file mode 100644
index 0000000..64e8a8a
--- /dev/null
+++ b/.github/workflows/coverage.yml
@@ -0,0 +1,26 @@
on: [ push, pull_request ]

name: Test coverage

jobs:
  coverage:
    name: Collect test coverage
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - uses: actions/checkout@v3
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview
      - name: Install latest nextest release
        uses: taiki-e/install-action@nextest
      - name: Install cargo-llvm-cov
        uses: taiki-e/install-action@cargo-llvm-cov
      - name: Collect coverage data
        run: cargo llvm-cov nextest --lcov --output-path lcov.info
      - name: Upload coverage data to codecov
        uses: codecov/codecov-action@v3
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
        with:
          files: lcov.info
diff --git a/src/util.rs b/src/util.rs
index 6df9967..3ccaf2e 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -1,16 +1,24 @@
use std::hash::Hasher;
use std::{
    borrow::Cow,
    fmt::{Display, Formatter},
    hash::Hash,
    ops::Deref,
    sync::Arc,
};

#[derive(Debug, Hash, Eq)]
#[derive(Debug, Eq)]
pub enum ArcOrCowStr {
    Arc(Arc<str>),
    Cow(Cow<'static, str>),
}

impl Hash for ArcOrCowStr {
    fn hash<H: Hasher>(&self, state: &mut H) {
        (**self).hash(state);
    }
}

impl PartialEq<ArcOrCowStr> for ArcOrCowStr {
    fn eq(&self, other: &ArcOrCowStr) -> bool {
        **self == **other