Crates.io | manyvecs |
lib.rs | manyvecs |
version | 0.3.0 |
source | src |
created_at | 2022-04-27 22:35:51.532217 |
updated_at | 2022-06-10 01:13:31.783093 |
description | Vector structs inspired by GLSL |
homepage | https://bd103.github.io |
repository | https://github.com/BD103/ManyVecs |
max_upload_size | |
id | 576461 |
size | 42,310 |
A library providing Vector structs inspired by GLSL. These are useful for working with coordinates, geometry, game development, and more. Some features include:
This is not related to the standard library Vec
type.
use manyvecs::legacy::Vec2;
// Vec2 stores two numbers, X and Y
let v = Vec2::<f32>::new(2.0, -0.5);
println!("{}, {}", v.x(), v.y());
// "2.0, -0.5"
// Operators work on vectors!
// They are applied componenet-wise.
println!("{}", v + 1.0);
// "Vec2(3.0, 0.5)"
// You can even create vecs from tuples
Vec2::from((2.0, 3.0));
These are just a few examples, you can find the complete documentation at docs.rs.
Versions 0.1.0 and 0.2.0 use a generic-based struct for its vectors. Version 0.3.0 onwards is introducing a macro-based struct. This is a breaking change, which is why you can configure these changes with features.
Note: In 1.0.0, generic-based vectors will be removed entirely.
Feature | Description |
---|---|
legacy |
The legacy feature enables generic-based vectors. It is toggled on by default for backward compatability. |
macroed |
The macroed feature enables macro-based vectors. It is toggled off by default. |
To enable macro-based vectors, include the following in your Cargo.toml
.
[dependencies]
manyvecs = { version = "~0.Y.Z", features = ["macroed"] }
To enable just the macro vector, include the following instead.
[dependencies]
manyvecs = { version = "~0.Y.Z", default-features = false, features = ["macroed"] }
The macroed and legacy features are designed to work side-by-side. Each have their own public module. If just legacy is enabled and not macroed, the contents of the legacy module will be exported to the root of the crate. Take a look at the following code in lib.rs
.
#[cfg(feature = "legacy")]
#[cfg(not(feature = "macroed"))]
pub use self::legacy::*;
The same applies for using just macroed and not legacy. This is important if you know you will not be using the other feature, as you can just use manyvecs::Vec2
instead of manyvecs::macroed::Vec2
.
This library is currently unstable. It is recommended that you only allow patches in your dependency on ManyVecs.
# Cargo.toml
[dependencies]
manyvecs = "~0.Y.Z"
See more about the tilde requirement here.
ManyVecs is developed and distributed under the MIT license.
Contributions are welcome! This is my (BD103's) first Rust crate ever published, so there is definitely room to improve.
Unless explicitly stated, any contribution intentionally submitted for inclusion to this project will be licensed as above, without any additional terms or conditions.