diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-14 00:14:30 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-14 00:14:30 +0800 |
| commit | 1f2462ae53446c37c6cfe53a57ea86f695c4ef0a (patch) | |
| tree | 9d54a4dcbaf1dc6fe36ecaf98253cbc521ddc8b0 /mingling_core/src/asset/node.rs | |
| parent | 47aa95b2c65473950e089beac6ac986a3240608e (diff) | |
docs: expand trait and type documentation with examples
Diffstat (limited to 'mingling_core/src/asset/node.rs')
| -rw-r--r-- | mingling_core/src/asset/node.rs | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/mingling_core/src/asset/node.rs b/mingling_core/src/asset/node.rs index b9002b6..ee28836 100644 --- a/mingling_core/src/asset/node.rs +++ b/mingling_core/src/asset/node.rs @@ -1,16 +1,39 @@ use just_fmt::kebab_case; -/// Represents a command node, used to match user-input command paths. +/// Represents a command node used for matching user-input command paths. /// -/// The node consists of multiple parts, each separated by a dot (`.`), and automatically converted to kebab-case. -/// For example, the input string `"node.subnode"` will be converted to a node representation of `["node", "subnode"]`. +/// The node consists of multiple segments, separated by dots (`.`), which are automatically +/// converted to kebab-case. For example, the input string `"node.subnode"` would be converted +/// to the node representation `["node", "subnode"]`. +/// +/// # Examples +/// +/// ``` +/// use mingling_core::Node; +/// +/// // Create a node and append child segments +/// let node = Node::from("base").join("sub").join("leaf"); +/// assert_eq!(node.to_string(), "base.sub.leaf"); +/// ``` #[derive(Debug, Default)] pub struct Node { node: Vec<String>, } impl Node { - /// Append a new part to the node path. + /// Appends a new segment to the node path. + /// + /// This method consumes the current node and returns a new node with the new + /// segment appended to the end of the path. + /// + /// # Examples + /// + /// ``` + /// use mingling_core::Node; + /// + /// let node = Node::from("base").join("sub"); + /// assert_eq!(node.to_string(), "base.sub"); + /// ``` #[must_use] pub fn join(self, node: impl Into<String>) -> Self { let mut new_node = self.node; |
