refactor: switch to array-init
- Use array-init for the lowest level vector operations. Makes them nicer and less bug-prone, with zero performance impact. - Remove unnecessary/unused ::new() functions on Vector and HeightVector. - Update README with new dependency. - Fix typo in README. Signed-off-by: Stephen Waits <steve@waits.net>
This commit is contained in:
1 parent
e20d9a284a
commit
f5dc99f7d3
4 files changed
+20
-32
No files matched your search
@@ -92,11 +92,6 @@ pub struct HeightVector<const N: usize> {
|
||||
//
|
||||
|
||||
impl<const N: usize> HeightVector<N> {
|
||||
/// A new height vector is a random unit vector
|
||||
pub(crate) fn new() -> Self {
|
||||
Self::random()
|
||||
}
|
||||
|
||||
/// A new height vector is a random unit vector
|
||||
pub(crate) fn random() -> Self {
|
||||
let mut rng = rand::thread_rng();
|
||||
@@ -131,7 +126,7 @@ impl<const N: usize> HeightVector<N> {
|
||||
ret
|
||||
} else {
|
||||
// if we have a bad vector, generate a new random vector
|
||||
Self::new()
|
||||
Self::random()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +313,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_new() {
|
||||
// new gives us a random unit length vec
|
||||
let a = HeightVector::<3>::new();
|
||||
let a = HeightVector::<3>::random();
|
||||
assert_approx_eq!(a.len(), 1.0);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user