nanvm_lib/vm/bigint/neg.rs
1use std::ops::Neg;
2
3use crate::{
4 common::sized_index::SizedIndex,
5 vm::{BigInt, IVm},
6};
7
8impl<A: IVm> Neg for BigInt<A> {
9 type Output = Self;
10 fn neg(self) -> Self::Output {
11 if self.is_zero() {
12 self
13 } else {
14 Self::unchecked_new(self.sign().flip(), self.index_iter())
15 }
16 }
17}