Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no_std support for bounded-vec #27

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -74,13 +74,20 @@ jobs:
with:
command: test
args: --verbose --release
- name: rust-tarpaulin code coverage check
if: matrix.os == 'ubuntu-latest'
uses: actions-rs/tarpaulin@master
with:
args: '--timeout=360 -v --out Lcov'

test_coverage:
name: Code coverage in tests
runs-on: ubuntu-latest
container:
image: xd009642/tarpaulin:latest
options: --security-opt seccomp=unconfined
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Generate code coverage
run: |
cargo tarpaulin --avoid-cfg-tarpaulin --timeout=360 --out lcov
- name: Push code coverage results to coveralls.io
if: matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -115,7 +122,7 @@ jobs:
with:
command: test
args: --verbose --release --all-features

doc-links:
name: Intra-documentation links
runs-on: ubuntu-latest
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -7,16 +7,16 @@ edition = "2018"
description = "Non-empty rust Vec wrapper with type guarantees on lower and upper bounds for items quantity."
repository = "https://github.com/ergoplatform/bounded-vec"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
thiserror = "1"
serde = {version = "1.0.123", features = ["derive"], optional = true}
proptest = {version = "1.0.0", optional = true}
serde = { version = "1.0.123", default-features = false, features = [
"alloc",
"derive",
], optional = true }
thiserror = { version = "2", default-features = false }
proptest = { version = "1.0.0", optional = true }

[features]
arbitrary = ["proptest"]

[dev-dependencies]
proptest = {version = "1.0.0"}
proptest = { version = "1.0.0" }
14 changes: 8 additions & 6 deletions src/bounded_vec.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use alloc::vec;
use alloc::vec::Vec;
use core::convert::{TryFrom, TryInto};
use core::slice::{Iter, IterMut};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::convert::{TryFrom, TryInto};
use std::slice::{Iter, IterMut};
use std::vec;
use thiserror::Error;

/// Non-empty Vec bounded with minimal (L - lower bound) and maximal (U - upper bound) items quantity
@@ -386,7 +387,7 @@
type IntoIter = core::slice::Iter<'a, T>;

fn into_iter(self) -> Self::IntoIter {
(&self.inner).iter()
self.inner.iter()
}
}

@@ -395,7 +396,7 @@
type IntoIter = core::slice::IterMut<'a, T>;

fn into_iter(self) -> Self::IntoIter {
(&mut self.inner).iter_mut()
self.inner.iter_mut()
}
}

@@ -423,9 +424,9 @@
}
}

/// Option<BoundedVec<T, _, _>> to Vec<T>

Check warning on line 427 in src/bounded_vec.rs

GitHub Actions / Intra-documentation links

unclosed HTML tag `T`
pub trait OptBoundedVecToVec<T> {
/// Option<BoundedVec<T, _, _>> to Vec<T>

Check warning on line 429 in src/bounded_vec.rs

GitHub Actions / Intra-documentation links

unclosed HTML tag `T`
fn to_vec(self) -> Vec<T>;
}

@@ -463,7 +464,7 @@
#[allow(clippy::unwrap_used)]
#[cfg(test)]
mod tests {
use std::convert::TryInto;
use core::convert::TryInto;

use super::*;

@@ -597,6 +598,7 @@
mod arb_tests {

use super::*;
use alloc::format;
use proptest::prelude::*;

proptest! {
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Non-empty Vec wrapper with lower and upper bounds on items quantity

#![no_std]
// Coding conventions
#![forbid(unsafe_code)]
#![deny(non_upper_case_globals)]
@@ -13,6 +14,8 @@
#![deny(clippy::unwrap_used)]
#![deny(clippy::expect_used)]

extern crate alloc;

mod bounded_vec;

pub use crate::bounded_vec::*;