Move the object with the given id to the given position. If the object is not found, nothing will happen. If the position is out of range, nothing will happen.
(&self, txn: &mut TransactionMut, from_id: &str, to_id: &str)
| 750 | /// If the object is not found, nothing will happen. |
| 751 | /// If the position is out of range, nothing will happen. |
| 752 | fn move_to(&self, txn: &mut TransactionMut, from_id: &str, to_id: &str) -> Option<()> { |
| 753 | let from = self.get_position_with_txn(txn, from_id)?; |
| 754 | let to = self.get_position_with_txn(txn, to_id)?; |
| 755 | let to = if from < to { to + 1 } else { to }; |
| 756 | trace!("Move object from {} to {}", from, to); |
| 757 | self.array_ref().move_to(txn, from, to); |
| 758 | None |
| 759 | } |
| 760 | |
| 761 | /// Returns the position of the object with the given id. |
| 762 | fn get_position_with_txn<T: ReadTxn>(&self, txn: &T, id: &str) -> Option<u32> { |
no test coverage detected