Skip to content

Commit

Permalink
Add defaults for vec and point (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
maplant authored Oct 22, 2024
1 parent 454d1c5 commit fb44966
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ This project adheres to [Semantic Versioning](http://semver.org/) as of version
## Unreleased Changes
These changes are included in `master` but have not been released in a new crate version yet.

## [v0.6.4]
- Add `Default` impl to `Vectors`.
- Add `Default` impl to `Points`.

## [v0.6.3]
- Fix `to_scale_rotation_translation` function
- Add `from_scale_rotation_translation` function
- Fix `to_scale_rotation_translation` function.
- Add `from_scale_rotation_translation` function.

## [v0.6.2]
- Fix `look_to_rh` function.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "al-jabr"
version = "0.6.3"
version = "0.6.4"
authors = ["Matthew Plant <[email protected]>", "Øystein Hovind <[email protected]>"]
edition = "2021"
description = "An n-dimensional linear algebra library."
Expand Down
6 changes: 6 additions & 0 deletions src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ macro_rules! implement_point {
}
}

impl<T: Zero> Default for $name<T> {
fn default() -> Self {
Self::origin()
}
}

impl<T> IntoIterator for $name<T> {
type Item = T;
type IntoIter = std::array::IntoIter<T, $size>;
Expand Down
9 changes: 9 additions & 0 deletions src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ macro_rules! implement_vector {
}
}

impl<T> Default for $name<T>
where
T: Zero,
{
fn default() -> Self {
Self::zero()
}
}

impl<T> From<[T; $size]> for $name<T> {
fn from(arr: [T; $size]) -> Self {
let [ x, $( $field, )* ] = arr;
Expand Down

0 comments on commit fb44966

Please sign in to comment.