diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b98ce1e..e137c50 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -52,10 +52,21 @@ jobs:
doc:
runs-on: ubuntu-latest
+ permissions:
+ contents: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- - run: cargo doc
+ - run: cargo doc --no-deps
+ - run: |
+ echo '
' > target/doc/index.html
+ if: github.ref == 'refs/heads/master'
+ - uses: peaceiris/actions-gh-pages@v4
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ publish_dir: ./target/doc
+ publish_branch: gh-pages
+ if: github.ref == 'refs/heads/master'
clippy:
runs-on: ubuntu-latest
diff --git a/Makefile b/Makefile
index 61878e2..8c34a97 100644
--- a/Makefile
+++ b/Makefile
@@ -27,10 +27,10 @@ bench:
xdg-open target/criterion/push\ and\ clear/report/index.html
doc:
- cargo doc --open
+ cargo doc --no-deps --open
build-doc:
- cargo doc
+ cargo doc --no-deps
dev:
echo Installing pre-commit hook...
diff --git a/README.md b/README.md
index dac4ef6..c5c9a77 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
[](https://opensource.org/licenses/MIT)
[](https://github.com/andreiavrammsd/static_vector.rs/actions/workflows/ci.yml)
[](https://codecov.io/gh/andreiavrammsd/static_vector.rs)
+[](https://andreiavrammsd.github.io/static_vector.rs/)
A no-std, stack-allocated vector with fixed capacity and dynamic length.
diff --git a/src/lib.rs b/src/lib.rs
index 006024b..5054b1e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -57,12 +57,14 @@ impl Vec {
/// Returns the maximum number of elements the vector can contain.
#[inline(always)]
+ #[doc(alias("max", "size", "limit", "length"))]
pub fn capacity(&self) -> usize {
CAPACITY
}
/// Returns the maximum number of elements the vector currenly contains.
#[inline(always)]
+ #[doc(alias("length", "size"))]
pub fn len(&self) -> usize {
self.length
}
@@ -79,6 +81,7 @@ impl Vec {
///
/// Returns [`CapacityExceededError`] if the vector is already at full capacity.
#[inline]
+ #[doc(alias("add", "append", "insert"))]
pub fn push(&mut self, value: &T) -> Result<(), CapacityExceededError> {
if self.length == CAPACITY {
return Err(CapacityExceededError);
@@ -92,6 +95,7 @@ impl Vec {
/// Removes all elements. Size will be zero.
#[inline]
+ #[doc(alias("reset", "remove", "truncate", "empty"))]
pub fn clear(&mut self) {
self.drop(0, self.length);
self.length = 0
@@ -107,6 +111,7 @@ impl Vec {
/// # Errors
///
/// Returns [`LengthTooLargeError`] if `new_length` exceeds the vector's fixed capacity.
+ #[doc(alias("resize", "length"))]
pub fn set_len(&mut self, new_length: usize) -> Result<(), LengthTooLargeError>
where
T: Default,
@@ -130,6 +135,7 @@ impl Vec {
/// Returns a reference to the first element in the vector, or [`None`] if the vector is empty.
#[must_use]
#[inline]
+ #[doc(alias("front", "head", "start"))]
pub fn first(&self) -> Option<&T> {
if self.length == 0 { None } else { Some(unsafe { &*self.data[0].as_ptr() }) }
}
@@ -137,6 +143,7 @@ impl Vec {
/// Returns a reference to the last element in the vector, or [`None`] if the vector is empty.
#[must_use]
#[inline]
+ #[doc(alias("back", "tail", "end"))]
pub fn last(&self) -> Option<&T> {
if self.length == 0 { None } else { Some(unsafe { &*self.data[self.length - 1].as_ptr() }) }
}
@@ -144,6 +151,7 @@ impl Vec {
/// Returns a reference to the element at the specified `index`, or [`None`] if out of bounds.
#[must_use]
#[inline]
+ #[doc(alias("at", "index"))]
pub fn get(&self, index: usize) -> Option<&T> {
if index >= self.length { None } else { Some(unsafe { &*self.data[index].as_ptr() }) }
}
@@ -151,6 +159,7 @@ impl Vec {
/// Returns a mutable reference to the element at the specified `index`, or [`None`] if out of bounds.
#[must_use]
#[inline]
+ #[doc(alias("at", "index"))]
pub fn get_mut(&mut self, index: usize) -> Option<&mut T> {
if index >= self.length {
None
@@ -162,6 +171,7 @@ impl Vec {
/// Returns (and removes) the last element from the vector, or [`None`] if the vector is empty.
#[must_use]
#[inline]
+ #[doc(alias("remove", "get"))]
pub fn pop(&mut self) -> Option {
if self.length == 0 {
None
@@ -175,6 +185,7 @@ impl Vec {
/// or [`None`] if the vector is empty or the predicate returns false.
#[must_use]
#[inline]
+ #[doc(alias("remove", "get"))]
pub fn pop_if(&mut self, predicate: impl FnOnce(&T) -> bool) -> Option {
let last = self.last()?;
if predicate(last) { self.pop() } else { None }