Pointer operation in Rust

Hi!

I am trying to write RBST, which is self-balancing binary search tree similar to Treap.
However, I have trouble with writing the operation written in C++ like following:

Node *merge(Node *left, Node *right) {
    if (left == nullptr) return right;
    if (right == nullptr) return left;
    if (rand() % (left->size + right->size) < left->size) {
        left->right = merge(left->right, right);
        update(left);
        return left;
    } else {
        // same as above, but left and right are swaped
    }
}

My code is here, but it produces compile errors in merge function.
In addition, I want to remove clone in split function to avoid consuming useless heap memory.

I tried to solve these problem for much time, but I could not.
I would be appreciate if someone will fix them.

Since the NodePtr is just an Option, maybe the Option::take() will be helpful?

It works and fixed version runs fast enough!
Thank you so much!