New node: String Split (#3304)

* Add two nodes for substring

* fix: number convention

* Remove unnecessay allocations and add support for \n in patterns

* Make split node return Vec<String> and remove count_elements node

* Add Cache implementations for Vec<String>

* Code review

---------

Co-authored-by: daniil.loban <daniil.loban@gmail.com>
Co-authored-by: Dennis Kobert <dennis@kobert.dev>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Daniil Loban
2025-11-04 00:02:12 +03:00
committed by GitHub
parent c4bbb7e880
commit 0d8c521fbe
6 changed files with 54 additions and 3 deletions

View File

@@ -88,7 +88,15 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
.iter()
.map(|field| match &field.ty {
ParsedFieldType::Regular(RegularParsedField { value_source, .. }) => match value_source {
ParsedValueSource::Default(data) => quote!(RegistryValueSource::Default(stringify!(#data))),
ParsedValueSource::Default(data) => {
// Check if the data is a string literal by parsing the token stream
let data_str = data.to_string();
if data_str.starts_with('"') && data_str.ends_with('"') && data_str.len() >= 2 {
quote!(RegistryValueSource::Default(#data))
} else {
quote!(RegistryValueSource::Default(stringify!(#data)))
}
}
ParsedValueSource::Scope(data) => quote!(RegistryValueSource::Scope(#data)),
_ => quote!(RegistryValueSource::None),
},