Skip to content

Commit 8334e79

Browse files
committed
Added serde support
Unfortunately serde does not seem to support const-generics yet. I put in an issue at serde-rs/serde#1272 for this, so we'll see where that goes.
1 parent e59b420 commit 8334e79

File tree

8 files changed

+68
-6
lines changed

8 files changed

+68
-6
lines changed

Cargo.lock

Lines changed: 57 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "quick_maths"
33
documentation = "https://docs.rs/quick_maths/"
4-
version = "0.1.1"
4+
version = "0.1.2"
55
authors = ["julianknodt <[email protected]>"]
66
edition = "2018"
77
readme = "readme.md"
@@ -13,12 +13,14 @@ homepage = "https://github.com/JulianKnodt/quick_maths"
1313

1414
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1515

16+
[features]
17+
default_f64 = []
18+
serialization=["serde"]
19+
1620
[dependencies]
1721
num = "0.2.0"
1822
cfg-if = "0.1.10"
19-
20-
[features]
21-
default_f64 = []
23+
serde = { version = "1.0", features = ["derive"], optional=true}
2224

2325
[profile.release]
2426
lto = true

readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,4 @@ allows for easy usage of the library without worrying unless you need to.
4040

4141
#### TODOs
4242

43-
- Add serde support
4443
- Add benchmarks

src/mat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use std::{
1212

1313
/// A matrix, where each vector represents a column
1414
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
15+
#[cfg_attr(feature="serialization", derive(serde::Serialize, serde::Deserialize))]
1516
pub struct Matrix<T = DefaultFloat, const M: usize, const N: usize>(pub [Vector<T, M>; N])
1617
where
1718
[T; M]: LengthAtMost32,

src/quat.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
vec::{Vec3, Vec4},
44
};
55

6+
/// Quats are Vec4's with implicit imaginary first three terms.
67
pub type Quat<T> = Vec4<T>;
78

89
impl<T: Float> Quat<T> {

src/ray.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::{
99
};
1010

1111
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
12+
#[cfg_attr(feature="serialization", derive(serde::Serialize, serde::Deserialize))]
1213
pub struct Ray<T = f32, V = Vec3<T>> {
1314
pub pos: V,
1415
pub dir: V,

src/transform.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{array::LengthAtMost32, ops::Mul};
55
/// Transform type which represents an easily invertible operator.
66
/// i.e. rotation in 3D, translation, etc.
77
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
8+
#[cfg_attr(feature="serialization", derive(serde::Serialize, serde::Deserialize))]
89
pub struct Transform<T = DefaultFloat, const N: usize>
910
where
1011
[T; N]: LengthAtMost32,

src/vec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::{
1313
/// Vector over floats and a const-size.
1414
/// Often used through Vec2, Vec3, and Vec4 instead of the raw struct.
1515
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd)]
16+
#[cfg_attr(feature="serialization", derive(serde::Serialize, serde::Deserialize))]
1617
pub struct Vector<T = DefaultFloat, const N: usize>(pub [T; N])
1718
where
1819
[T; N]: LengthAtMost32;

0 commit comments

Comments
 (0)