From 462eb83d14a9ccf13b520f02d283993a6c856552 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Sun, 18 May 2025 18:55:30 +0300 Subject: [PATCH 1/7] Add VS Code Coverage Gutters --- .vscode/extensions.json | 1 + .vscode/settings.json | 1 + Makefile | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 3d97f9e..137b74e 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ "rust-lang.rust-analyzer", + "ryanluker.vscode-coverage-gutters", ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 0cff5fa..99e7ad5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "files.insertFinalNewline": true, "files.trimFinalNewlines": true, + "coverage-gutters.coverageBaseDir": "**", } diff --git a/Makefile b/Makefile index 343bfe6..e46f28d 100644 --- a/Makefile +++ b/Makefile @@ -11,10 +11,14 @@ fmt: lint: cargo clippy --all-targets --all-features -coverage: +coverage-html: cargo llvm-cov --html open target/llvm-cov/html/index.html +# for VS Code Coverage Gutters +coverage-info: + cargo llvm-cov --all-features --workspace --lcov --output-path target/llvm-cov/lcov.info + bench: cargo bench xdg-open target/criterion/push\ and\ clear/report/index.html From 88be48b32c977e902fcf0f3d5cb4462dde24ca3c Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Sun, 18 May 2025 19:59:33 +0300 Subject: [PATCH 2/7] No wildcard imports --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index bb47a5e..3a02c3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,9 @@ opt-level = "z" [lints.rust] unsafe_code = "allow" +[lints.clippy] +wildcard_imports = "forbid" + [dev-dependencies] criterion = "0.6.0" From 8ec07980688f6ded44b6856cf500fcba4c13cbd0 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Sun, 18 May 2025 20:01:10 +0300 Subject: [PATCH 3/7] Forbid elided lifetimes --- Cargo.toml | 1 + src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3a02c3a..c6caf94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ opt-level = "z" [lints.rust] unsafe_code = "allow" +elided_lifetimes_in_paths = "forbid" [lints.clippy] wildcard_imports = "forbid" diff --git a/src/lib.rs b/src/lib.rs index cd6e2a9..c689212 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,13 +158,13 @@ impl Vec { /// Returns an iterator over immutable references to the elements in the vector. #[inline(always)] - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { Iter::new(&self.data, self.length) } /// Returns an iterator over mutable references to the elements in the vector. #[inline(always)] - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, T> { IterMut::new(&mut self.data, self.length) } From 65efca941e8211f334fb54c20790e4ff820b6f2c Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Sun, 18 May 2025 20:05:04 +0300 Subject: [PATCH 4/7] Verify doc --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27b5292..7eba6b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,9 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: components: rustfmt - - run: cargo fmt --all -- --check + - run: | + cargo fmt --all -- --check + cargo doc clippy: runs-on: ubuntu-latest From 63c2b4db74f618e28a7fbf4e570fbf56e7b6a64b Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Mon, 19 May 2025 18:25:13 +0300 Subject: [PATCH 5/7] Add no-std category --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c6caf94..feb535a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/andreiavrammsd/static_vector.rs" readme = "README.md" license = "MIT" keywords = ["vector"] -categories = ["data-structures"] +categories = ["data-structures", "no-std"] publish = false [profile.dev] From d5f1cb264650eb8890487e3abfbce9648af64d15 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Mon, 19 May 2025 21:24:11 +0300 Subject: [PATCH 6/7] Run doc in separate job --- .github/workflows/ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7eba6b0..b98ce1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,9 +48,14 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: components: rustfmt - - run: | - cargo fmt --all -- --check - cargo doc + - run: cargo fmt --all -- --check + + doc: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo doc clippy: runs-on: ubuntu-latest @@ -102,6 +107,7 @@ jobs: - format - clippy - coverage + - doc steps: - name: validate run: | From 72b4acf4ea9309baedcc13a8f929c532024687a1 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Tue, 20 May 2025 07:31:52 +0300 Subject: [PATCH 7/7] Use assume_init_drop --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index c689212..4e08357 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,7 +171,7 @@ impl Vec { fn drop(&mut self, from: usize, to: usize) { for i in from..to { unsafe { - self.data[i].as_mut_ptr().drop_in_place(); + self.data[i].assume_init_drop(); } } }