From 69b8d791364b18dc76be6f59ce3f0c67f630ab2a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 14 Aug 2026 18:24:44 +0800 Subject: docs: add StringVec documentation and usage examples --- mingling_core/src/program/string_vec.rs | 43 ++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'mingling_core/src') diff --git a/mingling_core/src/program/string_vec.rs b/mingling_core/src/program/string_vec.rs index 7af4bec..d38be85 100644 --- a/mingling_core/src/program/string_vec.rs +++ b/mingling_core/src/program/string_vec.rs @@ -1,7 +1,48 @@ -// Doc Not Optimize +/// A type wrapper around `Vec`. +/// +/// `StringVec` simplifies the process of creating a `Vec` from various +/// string collection types (such as arrays, slices, `Vec<&str>`, `Vec`, etc.) +/// by providing multiple convenient `From` conversion implementations. +/// It also implements [`Deref`] and `Into>`, allowing you to manipulate it +/// just like a regular `Vec`. +/// +/// # Examples +/// +/// ``` +/// # use mingling_core::StringVec; +/// // Create from a string array +/// let sv = StringVec::from(["hello", "world"]); +/// +/// // Has the Deref behavior of a regular Vec, can be used like a Vec +/// assert_eq!(sv.len(), 2); +/// assert_eq!(sv[0], "hello"); +/// +/// // Iterate +/// for s in sv.iter() { +/// println!("{}", s); +/// } +/// +/// // Convert back to Vec +/// let v: Vec = sv.into(); +/// assert_eq!(v, vec!["hello".to_string(), "world".to_string()]); +/// ``` +/// +/// # Supported conversion sources +/// +/// - `[&str; N]`: fixed-length string literal arrays +/// - `&[&str]`: string literal slice references +/// - `Vec<&str>`: string literal dynamic arrays +/// - `Vec`: `String` dynamic arrays (moved directly, no copy) +/// - `&[String]`: `String` slice references (shallow copies elements) +/// +/// # Notes +/// +/// This type is marked as `#[doc(hidden)]`, typically used internally +/// and not usually shown directly in public documentation. #[derive(Debug, Clone)] #[doc(hidden)] pub struct StringVec { + /// The internally stored actual string vector. vec: Vec, } -- cgit