swnb-complex

Crates.ioswnb-complex
lib.rsswnb-complex
version0.2.2
sourcesrc
created_at2022-09-28 07:23:06.093083
updated_at2022-09-28 08:36:43.198942
descriptioncomplex number lib
homepage
repositoryhttps://github.com/swnb/complex-rs
max_upload_size
id675478
size10,851
ZGY (swnb)

documentation

README

Rust Complex

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());
  }
Commit count: 17

cargo fmt