Skip to content

Commit d055f22

Browse files
avsaasesebcrozet
andauthored
Derive defmt::Format for public types (#1517)
* Derive defmt::Format for Matrix * Derive for other types in nalgebra * chore: update changelog --------- Co-authored-by: Sébastien Crozet <sebcrozet@dimforge.com>
1 parent ba30c9d commit d055f22

30 files changed

Lines changed: 30 additions & 0 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1010
### Added
1111

1212
- Add the `convert-glam030` feature to enable conversion from/to types from `glam` v0.30.
13+
- Add the `defmt` cargo feature that enables derives of `defmt::Format` for all no-std types.
1314

1415
### Changed
1516

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ glam028 = { package = "glam", version = "0.28", optional = true }
132132
glam029 = { package = "glam", version = "0.29", optional = true }
133133
glam030 = { package = "glam", version = "0.30", optional = true }
134134
rayon = { version = "1.6", optional = true }
135+
defmt = { version = "1.0.1", optional = true }
135136

136137
[dev-dependencies]
137138
serde_json = "1.0"

src/base/array_storage.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use std::mem;
4545
)
4646
)]
4747
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
48+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4849
pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
4950

5051
impl<T, const R: usize, const C: usize> ArrayStorage<T, R, C> {

src/base/dimension.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ dim_ops!(
219219
archive(as = "Self")
220220
)]
221221
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
222+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
222223
pub struct Const<const R: usize>;
223224

224225
/// Trait implemented exclusively by type-level integers.

src/base/matrix.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
174174
)
175175
)]
176176
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
177+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
177178
pub struct Matrix<T, R, C, S> {
178179
/// The data storage that contains all the matrix components. Disappointed?
179180
///

src/base/unit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use rkyv::bytecheck;
3838
)
3939
)]
4040
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
41+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4142
pub struct Unit<T> {
4243
pub(crate) value: T,
4344
}

src/geometry/dual_quaternion.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use simba::scalar::{ClosedNeg, RealField};
5757
)
5858
)]
5959
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
60+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6061
pub struct DualQuaternion<T> {
6162
/// The real component of the quaternion
6263
pub real: Quaternion<T>,

src/geometry/isometry.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ use rkyv::bytecheck;
8888
")
8989
)
9090
)]
91+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9192
pub struct Isometry<T, R, const D: usize> {
9293
/// The pure rotational part of this isometry.
9394
pub rotation: R,

src/geometry/orthographic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use rkyv::bytecheck;
3838
)]
3939
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
4040
#[derive(Copy, Clone)]
41+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4142
pub struct Orthographic3<T> {
4243
matrix: Matrix4<T>,
4344
}

src/geometry/perspective.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use rkyv::bytecheck;
4040
)]
4141
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
4242
#[derive(Copy, Clone)]
43+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
4344
pub struct Perspective3<T> {
4445
matrix: Matrix4<T>,
4546
}

0 commit comments

Comments
 (0)