vectorlib is both an executable binary that can be run, and a library that can be used in Rust programs.
Installing the command-line executable
Assuming you have Rust/Cargo installed , run this command in a terminal:
cargo install vectorlib
It will make the vectorlib command available in your PATH if you've allowed the PATH to be modified when installing Rust . cargo uninstall vectorlib uninstalls.
Adding vectorlib library as a dependency
Run this command in a terminal, in your project's directory:
cargo add vectorlib
To add it manually, edit your project's Cargo.toml file and add to the [dependencies] section:
vectorlib = "0.1.2"
The vectorlib library will be automatically available globally.
Read the vectorlib library documentation .
Back to the crate overview .
Readme
Vector2d Library
The following library is created for handling the vector for the animation library where we put our engine .
The libray has several modules and support
Changelog
2023 - 07 - 13 20 : 32 :
vectorlib is ready to be deployed.
2023 - 07 - 12 22 : 53 :
Now the implementation work for both . add ( ) method and the operators
for all the given operations (addition, subtractions, multiplication,
division)
2023 - 07 - 12 23 : 22 :
Finished adding the verboseVectors which will let us know when the
vector gets dropped from the memeory (useful for debugging purposes).
Implementing the test for all assocaited methods.
2023 - 07 - 10 21 : 36 : 30 :
Create the struct for the vectorlib
Support testing for unit test and library documentation test.
Imported to the Engine crate for our animation platform.
Notes
2023 - 07 - 12 22 : 24 :
For the verboseVectors I have used the composition of and built on top
of the vector2d. This was necessary since I cannot add a nother field
called verbose for the struct of Vector2d (stand Add , Sub , Div
and Mul needs only two fields).
For implementing the std:: fmt:: Display for the verboseVectors , I
found a creative way to extract first the Some ( vector) since Option is
not implementing for the Display trait, check the std:: fmt:: Display trait at the end of the verbose_vector2d_module.rs module.
2023 - 07 - 10 22 : 49 : 26 :
Up to this point the Vector2d supports
(+,-,*,/) operators for the vector
Input can be vector or scalar
. add ( ) , . div ( ) , . mul ( ) and . sub ( ) accepts only Vector2d cannot accept scalar
Meaning that let s = v. div ( 8. 0 ) will not work.
Features
Welcome message
You can run the command, for lunching the src/main.rs which is not
necessary, but I created for demostration purposes.
cargo run -- quiet
# or
cargo run -j 10 --quiet
Testing Module
Using the testing command below will run the test/tests.rs script along side
with the documentation scripts for each metho in the
vectorlib:: math:: vector_module:: Vector2d of Vector2d strcut methods.
cargo test
Sometimes we want to see the results output of some selected variables by the
specified test . To see the printed values during cargo test, you can use the
--nocapture flag. This flag prevents the test framework from capturing the
output, allowing the printed values to be displayed in the console.
cargo test -- --nocapture
# Or
cargo test -j 8 -- --nocapture