Library implementing fixed-length Vectors meant for representing dimensional values. Tested heavily to ensure safety during use.
```bash $ cd fixed-vectors $ cargo test ...
ok
as the test result.```
There are various examples implemented within the examples
directory to look at for getting started. If you would like to run an example within the examples
directory you can run the following commands.
bash
$ cd fixed-vectors
$ cargo run --example [EXAMPLE_NAME]
Custom Vector
Example below shows how you would create a custom Vector Struct.
```rust use fixedvectors::{Vector, implvector};
struct Vector5
impl_vector!(Vector5 { x, y, z, w, v }, 5);
fn main() {
println!("Vector5 Name: {}", Vector5::<()>::NAME);
println!("Vector5 Length: {}", Vector5::<()>::LEN);
println!("Vector5
let vector = Vector5::new(1, 2, 3, 4, 5);
println!("Vector: {}", vector);
println!("Vector Debug: {:?}", vector);
println!("Vector as Array: {:?}", vector.as_array());
println!("Vector as Vec: {:?}", vector.as_vec());
let mut sum = 0;
for i in vector { sum += i; }
println!("Vector Sum: {}", sum);
} ```
Tuplable Vector
Example below shows how you would implemented the TuplableVector Trait in a
Vector, as it's not currently implemented automatically with the impl_vector! Macro.
```rust use fixedvectors::{TuplableVector, implvector};
struct Vector2
impl_vector!(Vector2 { x, y }, 2);
impl
fn as_tuple(self) -> Self::Output {
return (self.x, self.y);
}
}
impl
fn main() { let tuple = Vector2::new("Vector", "2").astuple(); println!("Vector as Tuple: {:?}", tuple); asserteq!(tuple, ("Vector", "2")); } ```