Closed YichiZhang0613 closed 2 months ago
The behavior of assert!
is to panic if the condition is not met. The function already panics when gradient.len() == 0
. So, adding an assert!
would not change the behavior of the function (other than a better error message).
So, I am not sure what change you are proposing. There is no correct thing for it to return if gradient
is empty, so it must panic (or do worse things such as abort, but panicking is clearly better).
In all-is-cubes/all-is-cubes-content/src/alg.rs, I don't think the crash caused by
gradient.len() == 0
as comment read is the behavior we expect. So I think use assert! to check whether gradient.len() is equal to 0 before use it is a better way.