From ecf6f33b88cf8821bf87636f4ecc3b670415640a Mon Sep 17 00:00:00 2001 From: YoEight Date: Tue, 20 Jan 2026 23:13:41 -0500 Subject: [PATCH] feat: make name_to_type public --- src/analysis.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/analysis.rs b/src/analysis.rs index 0b93cd1..21a7048 100644 --- a/src/analysis.rs +++ b/src/analysis.rs @@ -1528,7 +1528,35 @@ impl<'a> Analysis<'a> { } } -fn name_to_type(opts: &AnalysisOptions, name: &str) -> Option { +/// Converts a type name string to its corresponding [`Type`] variant. +/// +/// This function performs case-insensitive matching for built-in type names and checks +/// against custom types defined in the analysis options. +/// +/// # Returns +/// +/// * `Some(Type)` - If the name matches a built-in type or custom type +/// * `None` - If the name doesn't match any known type +/// +/// # Built-in Type Mappings +/// +/// The following type names are recognized (case-insensitive): +/// - `"string"` → [`Type::String`] +/// - `"int"` or `"float64"` → [`Type::Number`] +/// - `"boolean"` → [`Type::Bool`] +/// - `"date"` → [`Type::Date`] +/// - `"time"` → [`Type::Time`] +/// - `"datetime"` → [`Type::DateTime`] +/// +/// # Examples +/// +/// ```ignore +/// let opts = AnalysisOptions::default(); +/// assert_eq!(name_to_type(&opts, "String"), Some(Type::String)); +/// assert_eq!(name_to_type(&opts, "INT"), Some(Type::Number)); +/// assert_eq!(name_to_type(&opts, "unknown"), None); +/// ``` +pub fn name_to_type(opts: &AnalysisOptions, name: &str) -> Option { if name.eq_ignore_ascii_case("string") { Some(Type::String) } else if name.eq_ignore_ascii_case("int") || name.eq_ignore_ascii_case("float64") {