pub fn destructive_hash(&mut self) -> usize {
        let stage = self.seq.len();

        // Initialise multiplier to (stage - 1)!
        let mut multiplier = 1;
        for i in 1..stage {
            multiplier *= i;
        }

        let mut i = stage - 1;
        let mut hash = 0;

        // Invariant:
        //   1) self.seq[..i] is a valid permutation
        //   2) multiplier = i!
        //   3) destructive_hash(self.seq[..i]) + hash = x
        //           where x is the output of the function
        while i > 0 {
            // Iterate to find the index of the bell represented by `i`
            for j in 0..stage {
                // Check if we've found the right bell
                if self.seq[j] == Bell::from(i) {
                    // Add the bell's index into our hash
                    hash += j * multiplier;

                    // Here, we could (and should for clarity) swap `self.seq[j]` and
                    // `self.seq[i]`, but since `seq[i]` will never be read, it is a waste of time
                    // setting it to any particular value.
                    self.seq[j] = self.seq[i];

                    // Break the loop, since the inner loop has done its work already
                    break;
                }
            }

            // Update both `i` and `multiplier` to preserve Invariant #2
            multiplier /= i;
            i -= 1;
        }

        // Return the accumulated hash value
        hash
    }
/// Hashes the change into the range `0..(stage)!`, but in the process it will destroy the
/// contents of `Change`.  In fact, it cannot be guarunteed that this function leaves this
/// `Change` representing a valid permutation.
///
/// Useful when proof checking on lower numbers, by creating a blank
/// table with a space for every possible change and then iterating over every row, filling in
/// the corresponding slot on the table.
///
/// # Example
/// ```
/// use bellmetal::Change;
///
/// let mut c = Change::from("14723865");
///
/// assert_eq!(c.destructive_hash(), 26939);
/// assert_ne!(c, Change::from("14723865"));
/// ```
Hashes the change into the range `0..(stage)!`, but in the process it will destroy the
contents of `Change`.  In fact, it cannot be guarunteed that this function leaves this
`Change` representing a valid permutation.

Useful when proof checking on lower numbers, by creating a blank
table with a space for every possible change and then iterating over every row, filling in
the corresponding slot on the table.
Hashes the change into the range ` 0 .. ( stage ) ! ` but in the process it will destroy the contents of ` Change ` . In fact it cannot be guarunteed that this function leaves this ` Change ` representing a valid permutation . Useful when proof checking on lower numbers by creating a blank table with a space for every possible change and then iterating over every row filling in the corresponding slot on the table .
pub fn destructive_hash(&mut self) -> usize {
        let stage = self.seq.len();
        // Initialise multiplier to (stage - 1)!
        let mut multiplier = 1;
        for i in 1..stage {
            multiplier *= i;
        }
        let mut i = stage - 1;
        let mut hash = 0;
        // Invariant:
        //   1) self.seq[..i] is a valid permutation
        //   2) multiplier = i!
        //   3) destructive_hash(self.seq[..i]) + hash = x
        //           where x is the output of the function
        while i > 0 {
            // Iterate to find the index of the bell represented by `i`
            for j in 0..stage {
                // Check if we've found the right bell
                if self.seq[j] == Bell::from(i) {
                    // Add the bell's index into our hash
                    hash += j * multiplier;
                    // Here, we could (and should for clarity) swap `self.seq[j]` and
                    // `self.seq[i]`, but since `seq[i]` will never be read, it is a waste of time
                    // setting it to any particular value.
                    self.seq[j] = self.seq[i];
                    // Break the loop, since the inner loop has done its work already
                    break;
                }
            }
            // Update both `i` and `multiplier` to preserve Invariant #2
            multiplier /= i;
            i -= 1;
        }
        // Return the accumulated hash value
        hash
    }
pub fn destructive_hash ( & mut self ) -> usize { let stage = self . seq . len ( ) ; // Initialise multiplier to (stage - 1)! let mut multiplier = 1 ; for i in 1 .. stage { multiplier *= i ; } let mut i = stage - 1 ; let mut hash = 0 ; // Invariant: //   1) self.seq[..i] is a valid permutation //   2) multiplier = i! //   3) destructive_hash(self.seq[..i]) + hash = x //           where x is the output of the function while i > 0 { // Iterate to find the index of the bell represented by `i` for j in 0 .. stage { // Check if we've found the right bell if self . seq [ j ] == Bell :: from ( i ) { // Add the bell's index into our hash hash += j * multiplier ; // Here, we could (and should for clarity) swap `self.seq[j]` and // `self.seq[i]`, but since `seq[i]` will never be read, it is a waste of time // setting it to any particular value. self . seq [ j ] = self . seq [ i ] ; // Break the loop, since the inner loop has done its work already break ; } } // Update both `i` and `multiplier` to preserve Invariant #2 multiplier /= i ; i -= 1 ; } // Return the accumulated hash value hash }
Hashes the change into the range `0..(stage)!`, but in the process it will destroy the
contents of `Change`.
Hashes the change into the range ` 0 .. ( stage ) ! ` but in the process it will destroy the contents of ` Change ` .
&mut self
&mut self
example
```
use bellmetal::Change.




` ` ` use bellmetal :: Change .