Skip to content

Commit 46628c2

Browse files
committed
fix formatting and clippy warnings
1 parent f4f52bd commit 46628c2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl<'a, T: 'a> NodeMut<'a, T> {
373373
let id = self.tree.orphan(value).id;
374374
self.prepend_id(id)
375375
}
376-
376+
377377
/// Insert a new child into this node at given index.
378378
/// This function may take up to linear time in worst case scenarios.
379379
///
@@ -493,17 +493,17 @@ impl<'a, T: 'a> NodeMut<'a, T> {
493493
/// Panics if `new_child_id` or `index` are not valid.
494494
pub fn insert_id(&mut self, new_child_id: NodeId, index: usize) -> NodeMut<T> {
495495
if index == 0 {
496-
return self.prepend_id(new_child_id)
496+
return self.prepend_id(new_child_id);
497497
}
498498

499499
let mut pre_sibling: NodeMut<T> = unsafe {
500500
self.tree
501-
.get_unchecked(self.id)
502-
.children()
503-
.nth(index - 1) // worst case O(n)
504-
.map(|node| node.id)
505-
.map(|id| self.tree.get_unchecked_mut(id))
506-
.expect(format!("No child found at index {}", index-1).as_str())
501+
.get_unchecked(self.id)
502+
.children()
503+
.nth(index - 1) // worst case O(n)
504+
.map(|node| node.id)
505+
.map(|id| self.tree.get_unchecked_mut(id))
506+
.unwrap_or_else(|| panic!("No child found at index {}", index - 1))
507507
};
508508

509509
pre_sibling.insert_id_after(new_child_id);

0 commit comments

Comments
 (0)