We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
from_indices
1 parent 0914ea9 commit 7799efaCopy full SHA for 7799efa
1 file changed
examples/sort-axis.rs
@@ -20,10 +20,14 @@ pub struct Permutation
20
impl Permutation
21
{
22
/// Checks if the permutation is correct
23
- pub fn from_indices(v: Vec<usize>) -> Option<Self>
+ pub fn from_indices(v: Vec<usize>) -> Result<Self, ()>
24
25
let perm = Permutation { indices: v };
26
- perm.correct().then_some(perm)
+ if perm.correct() {
27
+ Ok(perm)
28
+ } else {
29
+ Err(())
30
+ }
31
}
32
33
fn correct(&self) -> bool
0 commit comments