Explorar o código

:memo: added documentation for complex! macro

Felix Bytow %!s(int64=2) %!d(string=hai) anos
pai
achega
b067e1ecd9
Modificáronse 3 ficheiros con 23 adicións e 2 borrados
  1. 5 1
      CHANGELOG.md
  2. 1 1
      Cargo.toml
  3. 17 0
      src/types/complex.rs

+ 5 - 1
CHANGELOG.md

@@ -1,10 +1,14 @@
 # Changelog
 
+## Release 0.3.1
+
+- Added documentation to `complex!` macro.
+
 ## Release 0.3.0
 
 - `Numeric::whole` is now `unsafe`.
 - Renamed the mathematical functions (`fabs` to `abs`, `fsqrt` to `sqrt`, etc.).
-- added `complex!` macro for more comfortable `Complex` creation.
+- Added `complex!` macro for more comfortable `Complex` creation.
 
 ## Release 0.2.3
 

+ 1 - 1
Cargo.toml

@@ -5,7 +5,7 @@ description = "LINEar ALgebra"
 license = "MIT"
 repository = "https://git.drako.guru/drako/lineal-rs"
 readme = "README.md"
-version = "0.3.0"
+version = "0.3.1"
 edition = "2021"
 publish = ["crates-drako-guru"]
 

+ 17 - 0
src/types/complex.rs

@@ -32,6 +32,23 @@ pub struct Complex<T: Float + Numeric + Primitive> {
     pub imag: T,
 }
 
+/// A macro for easier creation of `Complex` numbers.
+///
+/// # Example
+///
+/// ```rust
+/// # use lineal::{Complex, complex};
+/// // just a real number
+/// let a = complex!(25.0);
+/// // first real, second imaginary
+/// let b = complex!(1.0, -1.0);
+/// // with named arguments
+/// let c = complex!(real = -1.0,);
+/// let d = complex!(imag = 1.0,);
+/// let e = complex!(real = 1.1, imag = 0.0,);
+/// // even reverse order
+/// let f = complex!(imag = 42.0, real = 23.0,);
+/// ```
 #[macro_export]
 macro_rules! complex {
     ($real:expr, $imag:expr) => {