capability-skeleton 0.1.0

A Rust library for managing and building complex hierarchical tree structures such as skill trees. Supports serialization, error handling, and deep tree metrics.
Documentation
// ---------------- [ File: capability-skeleton/src/skeleton_node_set_leaf_count.rs ]
crate::ix!();

impl SkeletonNode {

    /// Mutate `leaf_count`, turning this node into `LeafHolder` if needed.
    pub fn set_leaf_count(&mut self, new_count: u16) {
        match self {
            SkeletonNode::LeafHolder { leaf_count, .. } => {
                *leaf_count = new_count;
            }
            SkeletonNode::Dispatch { 
                id, parent_id, name, original_key, ordering, .. 
            } => {
                *self = SkeletonNode::LeafHolder {
                    id: *id,
                    parent_id: *parent_id,
                    leaf_count: new_count,
                    capstone: false,
                    name: name.clone(),
                    original_key: original_key.clone(),
                    ordering: ordering.clone(),
                };
            }
            SkeletonNode::Aggregate {
                id, parent_id, name, original_key, ordering, ..
            } => {
                *self = SkeletonNode::LeafHolder {
                    id: *id,
                    parent_id: *parent_id,
                    leaf_count: new_count,
                    capstone: false,
                    name: name.clone(),
                    original_key: original_key.clone(),
                    ordering: ordering.clone(),
                };
            }
        }
    }
}