Index Mathematics Conjectures nbv lettuce Widgets

assert_ne!

Fail compilation if two static vectors are equal at any index. Assertions

assert_ne! lhs, rhs[, "message"]

Compares two static vectors element by element while the program is compiled and stops compilation with an error at the first index where they are equal. Every element must differ, so assert_ne! [1 2], [1 3] fails. Nothing is added to the R1CS.

Arguments

lhs, rhs
Static vectors (or scalars) of equal length. Witness values are an error.
"message"
Optional string literal appended to the error.

Returns

Nothing, it is used as a statement. (The implementation returns lhs, but the grammar only accepts assert_ne! in statement position.)

Constraints

None.

Example

(let x)
static n = len! x
assert_ne! 0, n, "input must not be empty"
n
assert_ne! [1 2], [3 2]

Notes

Used in r1cs_from_vec to reject empty inputs. See also assert_eq!.

Used in the standard library

r1cs/r1cs_compose_vertical, r1cs/r1cs_from_vec, typed/typed_lex_width