Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
os: [ubuntu-latest]
rust:
- 1.55.0 # approximate MSRV is Stable -30
- 1.60.0 # approximate MSRV is Stable -30
- stable
- beta
- nightly
Expand All @@ -28,11 +28,11 @@ jobs:
toolchain: ${{ matrix.rust }}
# On MSRV some dev-dependencies don't build so we can't run tests.
- name: Check MSRV
if: matrix.rust == '1.55.0'
if: matrix.rust == '1.60.0'
run: |
cargo check --features=alloc,std,grab_spare_slice
- name: Test non nightly
if: matrix.rust != '1.55.0' && matrix.rust != 'nightly'
if: matrix.rust != '1.60.0' && matrix.rust != 'nightly'
run: |
cargo test --features=alloc,std,grab_spare_slice,latest_stable_rust
- name: Test on Nightly with All Features
Expand Down
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ arbitrary = { version = "1", optional = true }
borsh = { version = "1.2.0", optional = true, default-features = false }
# Implements the trait `Array` for `GenericArray` struct.
generic-array = { version = "1.1.1", optional = true, default-features = false }
# Provides `Format` implementations
defmt = { version = "1.0", optional = true }


[features]
Expand Down Expand Up @@ -76,12 +78,15 @@ experimental_write_impl = []
real_blackbox = ["criterion/real_blackbox"]

[package.metadata.docs.rs]
features = ["alloc", "std", "grab_spare_slice", "latest_stable_rust", "serde", "borsh"]
features = ["alloc", "std", "grab_spare_slice", "latest_stable_rust", "serde", "borsh", "defmt"]
rustdoc-args = ["--cfg","docs_rs"]

[package.metadata.playground]
features = ["alloc", "std", "grab_spare_slice", "latest_stable_rust", "serde", "borsh"]

[profile.dev]
lto = "thin"

[profile.bench]
debug = 2

Expand Down
23 changes: 23 additions & 0 deletions src/arrayvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ impl<A: Array> From<A> for ArrayVec<A> {
/// The error type returned when a conversion from a slice to an [`ArrayVec`]
/// fails.
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct TryFromSliceError(());

impl core::fmt::Display for TryFromSliceError {
Expand Down Expand Up @@ -1576,6 +1577,17 @@ where
}
}

#[cfg(feature = "defmt")]
#[cfg_attr(docs_rs, doc(cfg(feature = "defmt")))]
impl<A: Array> defmt::Format for ArrayVecIterator<A>
where
A::Item: defmt::Format,
{
fn format(&self, fmt: defmt::Formatter<'_>) {
defmt::write!(fmt, "ArrayVecIterator({:?})", self.as_slice())
}
}

impl<A: Array> IntoIterator for ArrayVec<A> {
type Item = A::Item;
type IntoIter = ArrayVecIterator<A>;
Expand Down Expand Up @@ -1716,6 +1728,17 @@ where
}
}

#[cfg(feature = "defmt")]
#[cfg_attr(docs_rs, doc(cfg(feature = "defmt")))]
impl<A: Array> defmt::Format for ArrayVec<A>
where
A::Item: defmt::Format,
{
fn format(&self, fmt: defmt::Formatter<'_>) {
defmt::Format::format(self.as_slice(), fmt)
}
}

impl<A: Array> Display for ArrayVec<A>
where
A::Item: Display,
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
//! * `borsh` provides a `BorshSerialize` and `BorshDeserialize` implementation
//! for [`TinyVec`] and [`ArrayVec`] types, provided the inner item also has
//! an implementation.
//! * `defmt` provides a `Format` implementation for all types, provided the
//! inner item also has an implementation.
//!
//! ## API
//! The general goal of the crate is that, as much as possible, the vecs here
Expand Down
11 changes: 11 additions & 0 deletions src/slicevec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,17 @@ where
}
}

#[cfg(feature = "defmt")]
#[cfg_attr(docs_rs, doc(cfg(feature = "defmt")))]
impl<'s, T> defmt::Format for SliceVec<'s, T>
where
T: defmt::Format,
{
fn format(&self, fmt: defmt::Formatter<'_>) {
defmt::Format::format(self.as_slice(), fmt)
}
}

impl<'s, T> Display for SliceVec<'s, T>
where
T: Display,
Expand Down
22 changes: 22 additions & 0 deletions src/tinyvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,17 @@ where
}
}

#[cfg(feature = "defmt")]
#[cfg_attr(docs_rs, doc(cfg(feature = "defmt")))]
impl<A: Array> defmt::Format for TinyVecIterator<A>
where
A::Item: defmt::Format,
{
fn format(&self, fmt: defmt::Formatter<'_>) {
defmt::write!(fmt, "TinyVecIterator({:?})", self.as_slice())
}
}

impl<A: Array> IntoIterator for TinyVec<A> {
type Item = A::Item;
type IntoIter = TinyVecIterator<A>;
Expand Down Expand Up @@ -1680,6 +1691,17 @@ where
}
}

#[cfg(feature = "defmt")]
#[cfg_attr(docs_rs, doc(cfg(feature = "defmt")))]
impl<A: Array> defmt::Format for TinyVec<A>
where
A::Item: defmt::Format,
{
fn format(&self, fmt: defmt::Formatter<'_>) {
defmt::Format::format(self.as_slice(), fmt)
}
}

impl<A: Array> Display for TinyVec<A>
where
A::Item: Display,
Expand Down