avltriee 0.78.0

Customized version of AVLTree library.Process the same value in the third branch. One data is immovable from one row, and positional relationships such as left, right, and parent are all referenced by row numbers. No search is required for value reference by specifying a row.
Documentation
use std::num::NonZeroU32;

#[derive(Clone, Debug, Default)]
pub struct AvltrieeNode<T> {
    pub(super) parent: Option<NonZeroU32>,
    pub(super) left: Option<NonZeroU32>,
    pub(super) right: Option<NonZeroU32>,
    pub(super) same: Option<NonZeroU32>,
    pub(super) height: u8,
    value: T,
}

impl<T> AvltrieeNode<T> {
    pub(crate) fn new(parent: Option<NonZeroU32>, value: T) -> Self {
        AvltrieeNode {
            height: 1,
            parent,
            left: None,
            right: None,
            same: None,
            value,
        }
    }

    pub(crate) fn changeling(&mut self, current_child: NonZeroU32, new_child: Option<NonZeroU32>) {
        if self.right == Some(current_child) {
            self.right = new_child;
        } else if self.left == Some(current_child) {
            self.left = new_child;
        }
    }

    pub(crate) fn same_clone(&mut self, self_row: NonZeroU32, new_row: NonZeroU32) -> Self
    where
        T: Clone,
    {
        let cloned = AvltrieeNode {
            height: self.height,
            parent: self.parent,
            left: self.left,
            right: self.right,
            same: Some(self_row),
            value: self.value.clone(),
        };
        self.left = None;
        self.right = None;
        self.parent = Some(new_row);

        cloned
    }
}

impl<T> std::ops::Deref for AvltrieeNode<T> {
    type Target = T;
    fn deref(&self) -> &Self::Target {
        &self.value
    }
}