| Crates.io | swnb-complex |
| lib.rs | swnb-complex |
| version | 0.2.2 |
| created_at | 2022-09-28 07:23:06.093083+00 |
| updated_at | 2022-09-28 08:36:43.198942+00 |
| description | complex number lib |
| homepage | |
| repository | https://github.com/swnb/complex-rs |
| max_upload_size | |
| id | 675478 |
| size | 10,851 |
rust implement for Complex Number
install
cargo add swnb-complex
usage
use swnb_complex::*;
fn main() {
let a = c!(3 + i 2);
let b = c!(2 - i 3);
let c = a * b;
assert_eq!(c, (12, -9 + 4).into());
let c = a + b;
assert_eq!(c, c!(5 - i 1));
let c = a - b;
assert_eq!(c, c!(1 + i 5));
assert_eq!(b - a, -c);
assert_eq!(a / b, (0, 1).into());
}