3 releases (breaking)

0.3.0 Jun 10, 2022
0.2.0 Jun 3, 2022
0.1.0 Apr 27, 2022

#18 in #legacy

Download history 1/week @ 2024-02-16 15/week @ 2024-02-23 9/week @ 2024-03-01 2/week @ 2024-03-08 1/week @ 2024-03-15 40/week @ 2024-03-29 13/week @ 2024-04-05

53 downloads per month

MIT license

40KB
1K SLoC

ManyVecs

A library providing Vector structs inspired by GLSL. These are useful for working with coordinates, geometry, game development, and more. Some features include:

  • In-depth unit testing
  • Support of component operators (addition, subtraction, etc.)
  • Useful methods, like magnitude and normalization

This is not related to the standard library Vec type.

Try it out!

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.

Features

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"] }

Exporting Content

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.

Stability Notice

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.

License

ManyVecs is developed and distributed under the MIT license.

Contributing

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.

Dependencies

~39KB