diff --git a/Cargo.toml b/Cargo.toml index 52d6ac7480..d7cb0080a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,7 +90,7 @@ default-features = false # version = "~0.2.0" # path = "module/core/type_constructor_meta" # default-features = false - +# # [workspace.dependencies.type_constructor_make_meta] # version = "~0.2.0" # path = "module/core/type_constructor_make_meta" diff --git a/module/core/component_model/tests/inc/components_tests/component_assign_manual.rs b/module/core/component_model/tests/inc/components_tests/component_assign_manual.rs index 19ac837500..142ef1750d 100644 --- a/module/core/component_model/tests/inc/components_tests/component_assign_manual.rs +++ b/module/core/component_model/tests/inc/components_tests/component_assign_manual.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use component_model::Assign; +use the_module::Assign; #[ derive( Default, PartialEq, Debug ) ] diff --git a/module/core/component_model/tests/inc/components_tests/components_assign_manual.rs b/module/core/component_model/tests/inc/components_tests/components_assign_manual.rs index 80efe86a79..a9e0de6ed2 100644 --- a/module/core/component_model/tests/inc/components_tests/components_assign_manual.rs +++ b/module/core/component_model/tests/inc/components_tests/components_assign_manual.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use component_model::{ Assign, AssignWithType }; +use the_module::{ Assign, AssignWithType }; /// /// Options1 @@ -42,7 +42,7 @@ impl From< &Options1 > for f32 } } -impl< IntoT > component_model::Assign< i32, IntoT > for Options1 +impl< IntoT > the_module::Assign< i32, IntoT > for Options1 where IntoT : Into< i32 >, { @@ -53,7 +53,7 @@ where } } -impl< IntoT > component_model::Assign< String, IntoT > for Options1 +impl< IntoT > the_module::Assign< String, IntoT > for Options1 where IntoT : Into< String >, { @@ -64,7 +64,7 @@ where } } -impl< IntoT > component_model::Assign< f32, IntoT > for Options1 +impl< IntoT > the_module::Assign< f32, IntoT > for Options1 where IntoT : Into< f32 >, { @@ -93,9 +93,9 @@ where // #[ allow( dead_code ) ] impl< T, IntoT > Options1ComponentsAssign< IntoT > for T where - T : component_model::Assign< i32, IntoT >, - T : component_model::Assign< String, IntoT >, - T : component_model::Assign< f32, IntoT >, + T : the_module::Assign< i32, IntoT >, + T : the_module::Assign< String, IntoT >, + T : the_module::Assign< f32, IntoT >, IntoT : Into< i32 >, IntoT : Into< String >, IntoT : Into< f32 >, @@ -104,9 +104,9 @@ where #[ inline( always ) ] fn options_1_assign( &mut self, component : IntoT ) { - component_model::Assign::< i32, _ >::assign( self, component.clone() ); - component_model::Assign::< String, _ >::assign( self, component.clone() ); - component_model::Assign::< f32, _ >::assign( self, component.clone() ); + the_module::Assign::< i32, _ >::assign( self, component.clone() ); + the_module::Assign::< String, _ >::assign( self, component.clone() ); + the_module::Assign::< f32, _ >::assign( self, component.clone() ); } } @@ -139,7 +139,7 @@ impl From< &Options2 > for String } } -impl< IntoT > component_model::Assign< i32, IntoT > for Options2 +impl< IntoT > the_module::Assign< i32, IntoT > for Options2 where IntoT : Into< i32 >, { @@ -150,7 +150,7 @@ where } } -impl< IntoT > component_model::Assign< String, IntoT > for Options2 +impl< IntoT > the_module::Assign< String, IntoT > for Options2 where IntoT : Into< String >, { @@ -176,8 +176,8 @@ where impl< T, IntoT > Options2ComponentsAssign< IntoT > for T where - T : component_model::Assign< i32, IntoT >, - T : component_model::Assign< String, IntoT >, + T : the_module::Assign< i32, IntoT >, + T : the_module::Assign< String, IntoT >, IntoT : Into< i32 >, IntoT : Into< String >, IntoT : Clone, @@ -185,8 +185,8 @@ where #[ inline( always ) ] fn options_2_assign( &mut self, component : IntoT ) { - component_model::Assign::< i32, _ >::assign( self, component.clone() ); - component_model::Assign::< String, _ >::assign( self, component.clone() ); + the_module::Assign::< i32, _ >::assign( self, component.clone() ); + the_module::Assign::< String, _ >::assign( self, component.clone() ); } } diff --git a/module/core/component_model/tests/inc/components_tests/composite_manual.rs b/module/core/component_model/tests/inc/components_tests/composite_manual.rs index 2003218fae..4f4b7b731d 100644 --- a/module/core/component_model/tests/inc/components_tests/composite_manual.rs +++ b/module/core/component_model/tests/inc/components_tests/composite_manual.rs @@ -1,7 +1,7 @@ #[ allow( unused_imports ) ] use super::*; #[ allow( unused_imports ) ] -use component_model::{ Assign, AssignWithType }; +use the_module::{ Assign, AssignWithType }; /// /// Options1 @@ -42,7 +42,7 @@ impl From< &Options1 > for f32 } } -impl< IntoT > component_model::Assign< i32, IntoT > for Options1 +impl< IntoT > the_module::Assign< i32, IntoT > for Options1 where IntoT : Into< i32 >, { @@ -53,7 +53,7 @@ where } } -impl< IntoT > component_model::Assign< String, IntoT > for Options1 +impl< IntoT > the_module::Assign< String, IntoT > for Options1 where IntoT : Into< String >, { @@ -64,7 +64,7 @@ where } } -impl< IntoT > component_model::Assign< f32, IntoT > for Options1 +impl< IntoT > the_module::Assign< f32, IntoT > for Options1 where IntoT : Into< f32 >, { @@ -91,9 +91,9 @@ where impl< T, IntoT > Options1ComponentsAssign< IntoT > for T where - T : component_model::Assign< i32, IntoT >, - T : component_model::Assign< String, IntoT >, - T : component_model::Assign< f32, IntoT >, + T : the_module::Assign< i32, IntoT >, + T : the_module::Assign< String, IntoT >, + T : the_module::Assign< f32, IntoT >, IntoT : Into< i32 >, IntoT : Into< String >, IntoT : Into< f32 >, @@ -102,9 +102,9 @@ where #[ inline( always ) ] fn options_1_assign( &mut self, component : IntoT ) { - component_model::Assign::< i32, _ >::assign( self, component.clone() ); - component_model::Assign::< String, _ >::assign( self, component.clone() ); - component_model::Assign::< f32, _ >::assign( self, component.clone() ); + the_module::Assign::< i32, _ >::assign( self, component.clone() ); + the_module::Assign::< String, _ >::assign( self, component.clone() ); + the_module::Assign::< f32, _ >::assign( self, component.clone() ); } } @@ -137,7 +137,7 @@ impl From< &Options2 > for String } } -impl< IntoT > component_model::Assign< i32, IntoT > for Options2 +impl< IntoT > the_module::Assign< i32, IntoT > for Options2 where IntoT : Into< i32 >, { @@ -148,7 +148,7 @@ where } } -impl< IntoT > component_model::Assign< String, IntoT > for Options2 +impl< IntoT > the_module::Assign< String, IntoT > for Options2 where IntoT : Into< String >, { @@ -174,8 +174,8 @@ where impl< T, IntoT > Options2ComponentsAssign< IntoT > for T where - T : component_model::Assign< i32, IntoT >, - T : component_model::Assign< String, IntoT >, + T : the_module::Assign< i32, IntoT >, + T : the_module::Assign< String, IntoT >, IntoT : Into< i32 >, IntoT : Into< String >, IntoT : Clone, @@ -183,8 +183,8 @@ where #[ inline( always ) ] fn options_2_assign( &mut self, component : IntoT ) { - component_model::Assign::< i32, _ >::assign( self, component.clone() ); - component_model::Assign::< String, _ >::assign( self, component.clone() ); + the_module::Assign::< i32, _ >::assign( self, component.clone() ); + the_module::Assign::< String, _ >::assign( self, component.clone() ); } } diff --git a/module/core/component_model_types/Readme.md b/module/core/component_model_types/Readme.md index fb9ae48ba8..723d84a2df 100644 --- a/module/core/component_model_types/Readme.md +++ b/module/core/component_model_types/Readme.md @@ -6,7 +6,7 @@ [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_component_model_types_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_component_model_types_push.yml) [![docs.rs](https://img.shields.io/docsrs/component_model_types?color=e3e8f0&logo=docs.rs)](https://docs.rs/component_model_types) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fcomponent_model_types%2Fexamples%2Fcomponent_model_types_trivial.rs,RUN_POSTFIX=--example%20module%2Fcore%2Fcomponent_model_types%2Fexamples%2Fcomponent_model_types_trivial.rs/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -A flexible implementation of the Builder pattern supporting nested builders and collection-specific subcomponent_models. Its compile-time structures and traits that are not generated but reused. +A flexible implementation of the Builder pattern supporting nested builders and collection-specific `subcomponent_models`. Its compile-time structures and traits that are not generated but reused. ## Example: Using Trait Assign diff --git a/module/core/component_model_types/src/lib.rs b/module/core/component_model_types/src/lib.rs index 0afa78e30f..0c10b3c969 100644 --- a/module/core/component_model_types/src/lib.rs +++ b/module/core/component_model_types/src/lib.rs @@ -18,13 +18,16 @@ pub mod dependency #[ doc( inline ) ] #[ cfg( feature = "enabled" ) ] +#[ allow( unused_imports ) ] pub use own::*; /// Own namespace of the module. #[ cfg( feature = "enabled" ) ] pub mod own { + #[ allow( unused_imports ) ] use crate::*; #[ doc( inline ) ] + #[ allow( unused_imports ) ] pub use crate::orphan::*; // Changed to crate::orphan::* } @@ -32,7 +35,9 @@ pub mod own #[ cfg( feature = "enabled" ) ] pub mod orphan { + #[ allow( unused_imports ) ] use crate::*; #[ doc( inline ) ] + #[ allow( unused_imports ) ] pub use crate::exposed::*; // Changed to crate::exposed::* } @@ -41,7 +46,9 @@ pub mod orphan #[ cfg( feature = "enabled" ) ] pub mod exposed { + #[ allow( unused_imports ) ] use crate::*; #[ doc( inline ) ] + #[ allow( unused_imports ) ] pub use crate::prelude::*; // Changed to crate::prelude::* } @@ -50,6 +57,7 @@ pub mod exposed #[ cfg( feature = "enabled" ) ] pub mod prelude { + #[ allow( unused_imports ) ] use crate::*; #[ doc( inline ) ] #[ cfg( feature = "types_component_assign" ) ] pub use crate::component::*; // Changed to crate::component::* diff --git a/module/core/component_model_types/tests/inc/mod.rs b/module/core/component_model_types/tests/inc/mod.rs index ce297bb341..5411331197 100644 --- a/module/core/component_model_types/tests/inc/mod.rs +++ b/module/core/component_model_types/tests/inc/mod.rs @@ -6,7 +6,6 @@ mod components_tests { use super::*; - #[ cfg( feature = "types_component_from" ) ] mod component_from_manual; #[ cfg( feature = "types_component_assign" ) ] diff --git a/module/core/component_model_types/tests/tests.rs b/module/core/component_model_types/tests/tests.rs index 5f3b8ea382..f2e9396a08 100644 --- a/module/core/component_model_types/tests/tests.rs +++ b/module/core/component_model_types/tests/tests.rs @@ -1,3 +1,4 @@ +//! Integration tests for the component_model_types crate. #![ allow( unused_imports ) ] include!( "../../../../module/step/meta/src/module/aggregating.rs" ); diff --git a/module/core/former/tests/inc/enum_unnamed_tests/tuple_zero_fields_manual.rs b/module/core/former/tests/inc/enum_unnamed_tests/tuple_zero_fields_manual.rs index 5183b220b6..0b1f54fec5 100644 --- a/module/core/former/tests/inc/enum_unnamed_tests/tuple_zero_fields_manual.rs +++ b/module/core/former/tests/inc/enum_unnamed_tests/tuple_zero_fields_manual.rs @@ -13,7 +13,7 @@ //! - Includes shared test logic from `tuple_zero_fields_only_test.rs`. //! - The included tests call these manually implemented methods/functions and assert that the returned enum instances match the direct enum variants. This verifies the manual implementation of constructors for zero-field tuple variants. -#[allow(unused_imports)] +#[ allow( unused_imports ) ] use ::former::prelude::*; use test_tools::exposed::*; use core::fmt::Debug; diff --git a/module/core/macro_tools/src/generic_params.rs b/module/core/macro_tools/src/generic_params.rs index 45c7d87eac..0e11fdeab0 100644 --- a/module/core/macro_tools/src/generic_params.rs +++ b/module/core/macro_tools/src/generic_params.rs @@ -187,8 +187,7 @@ mod private if self.syn_generics.params.is_empty() { Ok(quote::quote! { #base_ident }) - } else - { + } else { let (_, _, ty_g, _) = decompose_item_soft(self.syn_generics); Ok(quote::quote! { #base_ident ::< #ty_g > }) } diff --git a/module/core/mod_interface/tests/inc/derive/use_as/manual_only.rs b/module/core/mod_interface/tests/inc/derive/use_as/manual_only.rs index 9ce347e8fb..f6bb569e35 100644 --- a/module/core/mod_interface/tests/inc/derive/use_as/manual_only.rs +++ b/module/core/mod_interface/tests/inc/derive/use_as/manual_only.rs @@ -2,7 +2,7 @@ use layer_x as layer_a; #[doc(inline)] -#[allow(unused_imports)] +#[ allow( unused_imports ) ] pub use own :: * ; #[doc = r" Own namespace of the module."] @@ -12,11 +12,11 @@ pub mod own use super::*; #[doc(inline)] - #[allow(unused_imports)] + #[ allow( unused_imports ) ] pub use super :: orphan :: * ; #[doc(inline)] - #[allow(unused_imports)] + #[ allow( unused_imports ) ] #[doc = " layer_a"] pub use super :: layer_x :: orphan :: * ; @@ -29,7 +29,7 @@ pub mod orphan use super::*; #[doc(inline)] - #[allow(unused_imports)] + #[ allow( unused_imports ) ] pub use super :: exposed :: * ; } @@ -40,11 +40,11 @@ pub mod exposed { use super::*; #[doc(inline)] - #[allow(unused_imports)] + #[ allow( unused_imports ) ] pub use super :: prelude :: * ; #[doc(inline)] - #[allow(unused_imports)] + #[ allow( unused_imports ) ] #[doc = " layer_a"] pub use super :: layer_x :: exposed :: * ; } @@ -55,7 +55,7 @@ pub mod prelude { use super::*; #[doc(inline)] - #[allow(unused_imports)] + #[ allow( unused_imports ) ] #[doc = " layer_a"] pub use super :: layer_x :: prelude :: * ; } diff --git a/module/core/strs_tools/Cargo.toml b/module/core/strs_tools/Cargo.toml index a7ec89cdc6..a6a99117e3 100644 --- a/module/core/strs_tools/Cargo.toml +++ b/module/core/strs_tools/Cargo.toml @@ -57,10 +57,8 @@ string_split = [ "enabled" ] # Removed circular dependency on string_parse_reque string_parse = [] [dependencies] -lexical = { version = "~6.1", optional = true } +lexical = { version = "7.0.4", optional = true } component_model_types = { workspace = true, features = ["enabled"] } -mod_interface = { workspace = true } -mod_interface_meta = { workspace = true, features = ["enabled"] } [dev-dependencies] test_tools = { workspace = true } diff --git a/module/core/strs_tools/Readme.md b/module/core/strs_tools/Readme.md index 2f8bab872e..f8ee799f4b 100644 --- a/module/core/strs_tools/Readme.md +++ b/module/core/strs_tools/Readme.md @@ -1,5 +1,5 @@ - + # Module :: `strs_tools` [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental) [![rust-status](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml/badge.svg)](https://github.com/Wandalen/wTools/actions/workflows/module_strs_tools_push.yml) [![docs.rs](https://img.shields.io/docsrs/strs_tools?color=e3e8f0&logo=docs.rs)](https://docs.rs/strs_tools) [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=module%2Fcore%2Fstrs_tools%2Fexamples%2Fstrs_tools_trivial.rs,RUN_POSTFIX=--example%20module%2Fcore%2Fstrs_tools%2Fexamples%2Fstrs_tools_trivial.rs/https://github.com/Wandalen/wTools) [![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) @@ -12,7 +12,7 @@ Tools to manipulate strings. ```rust -#[ cfg( all( feature = "split", not( feature = "no_std" ) ) ) ] +#[ cfg( all( feature = "string_split", not( feature = "no_std" ) ) ) ] { /* delimeter exists */ let src = "abc def"; @@ -21,7 +21,7 @@ Tools to manipulate strings. .delimeter( " " ) .stripping( false ) .perform(); - let iterated = iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(); + let iterated = iter.map( | e | String::from( e.string ) ).collect::< Vec< _ > >(); assert_eq!( iterated, vec![ "abc", " ", "def" ] ); /* delimeter not exists */ @@ -30,7 +30,7 @@ Tools to manipulate strings. .src( src ) .delimeter( "g" ) .perform(); - let iterated = iter.map( | e | String::from( e ) ).collect::< Vec< _ > >(); + let iterated = iter.map( | e | String::from( e.string ) ).collect::< Vec< _ > >(); assert_eq!( iterated, vec![ "abc def" ] ); } ``` @@ -41,17 +41,28 @@ Tools to manipulate strings. cargo add strs_tools ``` +### Features + +This crate uses a feature-based system to allow you to include only the functionality you need. Key features include: + +* `string_indentation`: Tools for adding indentation to lines of text. +* `string_isolate`: Functions to isolate parts of a string based on delimiters. +* `string_parse_request`: Utilities for parsing command-like strings with subjects and key-value parameters. +* `string_parse_number`: Functions for parsing numerical values from strings. +* `string_split`: Advanced string splitting capabilities with various options for delimiters, quoting, and segment preservation. + +You can enable features in your `Cargo.toml` file, for example: +```toml +[dependencies.strs_tools] +version = "0.18.0" # Or your desired version +features = [ "string_split", "string_indentation" ] +``` +The `default` feature enables a common set of functionalities. The `full` feature enables all available string utilities. Refer to the `Cargo.toml` for a complete list of features and their dependencies. + ### Try out from the repository ```sh git clone https://github.com/Wandalen/wTools -cd wTools -cd examples/wstring_tools_trivial -cargo run +cd wTools/module/core/strs_tools +cargo run --example strs_tools_trivial ``` - -# Sample - -[![discord](https://img.shields.io/discord/872391416519737405?color=eee&logo=discord&logoColor=eee&label=ask)](https://discord.gg/m3YfbXpUUY) -[![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=sample%2Frust%2Fstrs_tools_trivial,SAMPLE_FILE=.%2Fsrc%2Fmain.rs/https://github.com/Wandalen/wTools) -[![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/strs_tools) diff --git a/module/core/strs_tools/src/lib.rs b/module/core/strs_tools/src/lib.rs index 7c446df4d6..287e2714d3 100644 --- a/module/core/strs_tools/src/lib.rs +++ b/module/core/strs_tools/src/lib.rs @@ -18,8 +18,9 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use orphan::*; + pub use super::string; // Added pub use super::string::orphan::*; } @@ -28,8 +29,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { - - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use exposed::*; } @@ -38,7 +38,8 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { - use super::*; + #[ allow( unused_imports ) ] use super::*; + pub use prelude::*; // Added pub use super::string::exposed::*; } @@ -47,6 +48,6 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use super::string::prelude::*; } diff --git a/module/core/strs_tools/src/string/indentation.rs b/module/core/strs_tools/src/string/indentation.rs index 865364f017..3322a64330 100644 --- a/module/core/strs_tools/src/string/indentation.rs +++ b/module/core/strs_tools/src/string/indentation.rs @@ -77,8 +77,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { - - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use orphan::*; pub use private:: { @@ -89,8 +88,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { - - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use exposed::*; pub use private:: { @@ -101,8 +99,8 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { - - use super::*; + #[ allow( unused_imports ) ] use super::*; + pub use prelude::*; // Added pub use super::own as indentation; pub use private:: @@ -115,6 +113,5 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { - - use super::*; + #[ allow( unused_imports ) ] use super::*; } diff --git a/module/core/strs_tools/src/string/isolate.rs b/module/core/strs_tools/src/string/isolate.rs index 1845c33701..1f5738a676 100644 --- a/module/core/strs_tools/src/string/isolate.rs +++ b/module/core/strs_tools/src/string/isolate.rs @@ -213,9 +213,10 @@ pub mod private #[ allow( unused_imports ) ] pub mod own { - use super::*; + #[ allow( unused_imports ) ] use super::*; use super::private as i; + pub use orphan::*; // Added pub use i::IsolateOptions; // pub use i::IsolateOptionsAdapter; // Removed pub use i::isolate; @@ -229,8 +230,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod orphan { - - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use exposed::*; } @@ -238,7 +238,8 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { - use super::*; + #[ allow( unused_imports ) ] use super::*; + pub use prelude::*; // Added pub use super::own as isolate; use super::private as i; @@ -253,7 +254,7 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + #[ allow( unused_imports ) ] use super::*; use super::private as i; // pub use i::IsolateOptionsAdapter; // Removed diff --git a/module/core/strs_tools/src/string/mod.rs b/module/core/strs_tools/src/string/mod.rs index 874c55e919..77f98fb67c 100644 --- a/module/core/strs_tools/src/string/mod.rs +++ b/module/core/strs_tools/src/string/mod.rs @@ -1,4 +1,3 @@ - /// Add indentation to each line. #[ cfg( all( feature = "string_indentation", not( feature = "no_std" ) ) ) ] pub mod indentation; @@ -33,66 +32,75 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { + // Removed: #[ allow( unused_imports ) ] use super::*; - use super::*; - - pub use orphan::*; + pub use super::orphan::*; // Corrected #[ cfg( all( feature = "string_indentation", not( feature = "no_std" ) ) ) ] - pub use super::indentation::orphan::*; + // pub use self::indentation; // Removed + // #[ cfg( all( feature = "string_indentation", not( feature = "no_std" ) ) ) ] // Redundant cfg + pub use super::indentation::orphan::*; // Corrected #[ cfg( all( feature = "string_isolate", not( feature = "no_std" ) ) ) ] - pub use super::isolate::orphan::*; + // pub use self::isolate; // Removed + // #[ cfg( all( feature = "string_isolate", not( feature = "no_std" ) ) ) ] // Redundant cfg + pub use super::isolate::orphan::*; // Corrected #[ cfg( all( feature = "string_parse_number", not( feature = "no_std" ) ) ) ] + // pub use self::number; // Removed + // #[ cfg( all( feature = "string_parse_number", not( feature = "no_std" ) ) ) ] // Redundant cfg #[ allow( unused_imports ) ] - pub use super::number::orphan::*; + pub use super::number::orphan::*; // Corrected #[ cfg( all( feature = "string_parse_request", not( feature = "no_std" ) ) ) ] - pub use super::parse_request::orphan::*; + // pub use self::parse_request; // Removed + // #[ cfg( all( feature = "string_parse_request", not( feature = "no_std" ) ) ) ] // Redundant cfg + pub use super::parse_request::orphan::*; // Corrected #[ cfg( all( feature = "string_split", not( feature = "no_std" ) ) ) ] - pub use super::split::orphan::*; + // pub use self::split; // Removed + // #[ cfg( all( feature = "string_split", not( feature = "no_std" ) ) ) ] // Redundant cfg + pub use super::split::orphan::*; // Corrected } /// Parented namespace of the module. #[ allow( unused_imports ) ] pub mod orphan { - - use super::*; - pub use exposed::*; + #[ allow( unused_imports ) ] use super::*; + pub use super::exposed::*; // Corrected } /// Exposed namespace of the module. #[ allow( unused_imports ) ] pub mod exposed { - use super::*; + // Removed: #[ allow( unused_imports ) ] use super::*; + pub use super::prelude::*; // Corrected #[ cfg( all( feature = "string_indentation", not( feature = "no_std" ) ) ) ] #[ allow( unused_imports ) ] - pub use super::indentation::exposed::*; + pub use super::indentation::exposed::*; // Corrected #[ cfg( all( feature = "string_isolate", not( feature = "no_std" ) ) ) ] - pub use super::isolate::exposed::*; + pub use super::isolate::exposed::*; // Corrected #[ cfg( all( feature = "string_parse_number", not( feature = "no_std" ) ) ) ] #[ allow( unused_imports ) ] - pub use super::number::exposed::*; + pub use super::number::exposed::*; // Corrected #[ cfg( all( feature = "string_parse_request", not( feature = "no_std" ) ) ) ] - pub use super::parse_request::exposed::*; + pub use super::parse_request::exposed::*; // Corrected #[ cfg( all( feature = "string_split", not( feature = "no_std" ) ) ) ] - pub use super::split::exposed::*; + pub use super::split::exposed::*; // Corrected } /// Namespace of the module to include with `use module::*`. #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + #[ allow( unused_imports ) ] use super::*; #[ cfg( all( feature = "string_indentation", not( feature = "no_std" ) ) ) ] #[ allow( unused_imports ) ] - pub use super::indentation::prelude::*; + pub use super::indentation::prelude::*; // Corrected #[ cfg( all( feature = "string_isolate", not( feature = "no_std" ) ) ) ] - pub use super::isolate::prelude::*; + pub use super::isolate::prelude::*; // Corrected #[ cfg( all( feature = "string_parse_number", not( feature = "no_std" ) ) ) ] #[ allow( unused_imports ) ] - pub use super::number::prelude::*; + pub use super::number::prelude::*; // Corrected #[ cfg( all( feature = "string_parse_request", not( feature = "no_std" ) ) ) ] - pub use super::parse_request::prelude::*; + pub use super::parse_request::prelude::*; // Corrected #[ cfg( all( feature = "string_split", not( feature = "no_std" ) ) ) ] - pub use super::split::prelude::*; + pub use super::split::prelude::*; // Corrected } diff --git a/module/core/strs_tools/src/string/number.rs b/module/core/strs_tools/src/string/number.rs index a89345bba5..7b632ef117 100644 --- a/module/core/strs_tools/src/string/number.rs +++ b/module/core/strs_tools/src/string/number.rs @@ -11,8 +11,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { - - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use orphan::*; pub use private:: { @@ -27,8 +26,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { - - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use exposed::*; pub use private:: { @@ -39,8 +37,8 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { - - use super::*; + #[ allow( unused_imports ) ] use super::*; + pub use prelude::*; // Added pub use super::own as number; pub use private:: @@ -52,5 +50,5 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { - use super::*; + #[ allow( unused_imports ) ] use super::*; } diff --git a/module/core/strs_tools/src/string/parse_request.rs b/module/core/strs_tools/src/string/parse_request.rs index 9715ecacdd..267c3e4e42 100644 --- a/module/core/strs_tools/src/string/parse_request.rs +++ b/module/core/strs_tools/src/string/parse_request.rs @@ -8,7 +8,6 @@ mod private use string:: { - split::*, isolate::isolate_right, // Keep the import for the function }; use super::*; @@ -52,7 +51,7 @@ mod private } #[ allow( clippy::from_over_into ) ] - impl< T > Into > for OpType< T > + impl< T > Into> for OpType< T > { fn into( self ) -> Vec< T > { @@ -146,7 +145,7 @@ mod private pub original : &'a str, /// Delimiter for pairs `key:value`. pub key_val_delimeter : &'a str, - /// Delimeter for commands. + /// Delimiter for commands. pub commands_delimeter : &'a str, /// Parsed subject of first command. pub subject : String, @@ -544,8 +543,7 @@ pub use own::*; #[ allow( unused_imports ) ] pub mod own { - - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use orphan::*; pub use private:: { @@ -561,8 +559,7 @@ pub mod own #[ allow( unused_imports ) ] pub mod orphan { - - use super::*; + #[ allow( unused_imports ) ] use super::*; pub use exposed::*; } @@ -570,8 +567,8 @@ pub mod orphan #[ allow( unused_imports ) ] pub mod exposed { - - use super::*; + #[ allow( unused_imports ) ] use super::*; + pub use prelude::*; // Added pub use super::own as parse_request; pub use private:: @@ -585,7 +582,6 @@ pub mod exposed #[ allow( unused_imports ) ] pub mod prelude { - - use super::*; + #[ allow( unused_imports ) ] use super::*; // pub use private::ParseOptionsAdapter; // Removed } diff --git a/module/core/strs_tools/src/string/split.rs b/module/core/strs_tools/src/string/split.rs index 027a2aca88..1eb75926bb 100644 --- a/module/core/strs_tools/src/string/split.rs +++ b/module/core/strs_tools/src/string/split.rs @@ -28,6 +28,7 @@ mod private } } + /// Defines the type of a split segment, either a delimited part or the delimiter itself. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum SplitType { @@ -37,8 +38,10 @@ mod private Delimeter, } + /// Trait for finding the position of a delimiter pattern within a string. pub trait Searcher { + /// Finds the first occurrence of the pattern in `src`. Returns a tuple of (start, end) byte indices if found. fn pos( &self, src : &str ) -> Option< ( usize, usize ) >; } @@ -79,6 +82,7 @@ mod private } } + /// A fast, low-level iterator for splitting strings based on a delimiter. Alternates between delimited segments and delimiters. #[ derive( Debug ) ] pub struct SplitFastIterator< 'a, D > where @@ -92,6 +96,7 @@ mod private impl< 'a, D : Searcher + Clone > SplitFastIterator< 'a, D > { + /// Creates a new `SplitFastIterator` with the given options. #[ allow( dead_code, clippy::needless_pass_by_value ) ] fn new( o : impl SplitOptionsAdapter< 'a, D > ) -> Self { @@ -167,6 +172,7 @@ mod private } } + /// An iterator for splitting strings with advanced options like stripping, preserving empty segments, and handling quotes. #[ derive( Debug ) ] #[ allow( clippy::struct_excessive_bools ) ] pub struct SplitIterator< 'a > @@ -184,6 +190,7 @@ mod private impl< 'a > SplitIterator< 'a > { + /// Creates a new `SplitIterator` with the given options. #[ allow( clippy::needless_pass_by_value ) ] fn new( o : impl SplitOptionsAdapter< 'a, Vec< &'a str > > ) -> Self { @@ -342,6 +349,7 @@ mod private } } + /// Options for configuring string splitting behavior for `SplitIterator` and `SplitFastIterator` generic over delimiter type. #[ derive( Debug ) ] #[ allow( clippy::struct_excessive_bools ) ] pub struct SplitOptions< 'a, D > @@ -361,6 +369,7 @@ mod private impl< 'a > SplitOptions< 'a, Vec< &'a str > > { + /// Consumes the options and returns a `SplitIterator` for splitting with a `Vec<&str>` delimiter. #[ must_use ] pub fn split( self ) -> SplitIterator< 'a > { SplitIterator::new( self ) } } @@ -369,19 +378,30 @@ mod private where D : Searcher + Default + Clone { + /// Consumes the options and returns a `SplitFastIterator` for splitting. pub fn split_fast( self ) -> SplitFastIterator< 'a, D > { SplitFastIterator::new( self ) } } + /// Adapter trait to provide a consistent interface for split options. pub trait SplitOptionsAdapter< 'a, D > where D : Clone { + /// The source string to be split. fn src( &self ) -> &'a str; + /// The delimiter(s) to split the string by. fn delimeter( &self ) -> D; + /// Whether to preserve empty segments. fn preserving_empty( &self ) -> bool; + /// Whether to preserve delimiters as part of the iteration. fn preserving_delimeters( &self ) -> bool; + /// Whether to preserve quoting characters in the output segments. fn preserving_quoting( &self ) -> bool; + /// Whether to strip leading/trailing whitespace from delimited segments. fn stripping( &self ) -> bool; + /// Whether to enable quote handling. fn quoting( &self ) -> bool; + /// Prefixes that start a quoted section. fn quoting_prefixes( &self ) -> &Vec< &'a str >; + /// Postfixes that end a quoted section. fn quoting_postfixes( &self ) -> &Vec< &'a str >; } @@ -398,6 +418,7 @@ mod private fn quoting_postfixes( &self ) -> &Vec< &'a str > { &self.quoting_postfixes } } + /* macro_rules! builder_impls_from { ( $name : ident, $( ( $field : ident, $type : ty ) ),* $( , )? ) => @@ -428,7 +449,9 @@ mod private } } } + */ + /// A builder for `SplitOptions` to configure string splitting. #[ allow( clippy::struct_excessive_bools ) ] #[ derive( Debug ) ] pub struct SplitOptionsFormer< 'a > @@ -443,16 +466,17 @@ mod private quoting_prefixes : Vec< &'a str >, quoting_postfixes : Vec< &'a str >, } - builder_impls_from! - ( - SplitOptionsFormer, - ( preserving_empty, bool ), ( preserving_delimeters, bool ), ( preserving_quoting, bool ), - ( stripping, bool ), ( quoting, bool ), - ( quoting_prefixes, Vec< &'a str > ), ( quoting_postfixes, Vec< &'a str > ), - ); + // builder_impls_from! + // ( + // SplitOptionsFormer, + // ( preserving_empty, bool ), ( preserving_delimeters, bool ), ( preserving_quoting, bool ), + // ( stripping, bool ), ( quoting, bool ), + // ( quoting_prefixes, Vec< &'a str > ), ( quoting_postfixes, Vec< &'a str > ), + // ); impl< 'a > SplitOptionsFormer< 'a > { + /// Creates a new `SplitOptionsFormer` with a default delimiter. pub fn new< D : Into< OpType< &'a str > > >( delimeter : D ) -> SplitOptionsFormer< 'a > { Self @@ -465,22 +489,118 @@ mod private quoting_prefixes : vec![], quoting_postfixes : vec![], } } + + // Manually added setters + /// Sets whether to preserve empty segments. + pub fn preserving_empty( &mut self, value : bool ) -> &mut Self { self.preserving_empty = value; self } + /// Sets whether to preserve delimiters. + pub fn preserving_delimeters( &mut self, value : bool ) -> &mut Self { self.preserving_delimeters = value; self } + /// Sets whether to preserve quoting characters. + pub fn preserving_quoting( &mut self, value : bool ) -> &mut Self { self.preserving_quoting = value; self } + /// Sets whether to strip whitespace from segments. + pub fn stripping( &mut self, value : bool ) -> &mut Self { self.stripping = value; self } + /// Sets whether to enable quote handling. + pub fn quoting( &mut self, value : bool ) -> &mut Self { self.quoting = value; self } + /// Sets the quoting prefixes. + pub fn quoting_prefixes( &mut self, value : Vec< &'a str > ) -> &mut Self { self.quoting_prefixes = value; self } + /// Sets the quoting postfixes. + pub fn quoting_postfixes( &mut self, value : Vec< &'a str > ) -> &mut Self { self.quoting_postfixes = value; self } + + // Existing methods that were likely part of the manual impl before, or should be retained + /// Sets the source string to split. + pub fn src( &mut self, value : &'a str ) -> &mut Self { self.src = value; self } + /// Sets the delimiter(s). pub fn delimeter< D : Into< OpType< &'a str > > >( &mut self, value : D ) -> &mut Self { self.delimeter = OpType::Vector( vec![] ).append( value.into() ); self } - pub fn src( &mut self, value : &'a str ) -> &mut Self { self.src = value; self } + + // Manually added form method + /// Consumes the builder and returns `SplitOptions` configured for `Vec<&str>` delimiter. + pub fn form( &mut self ) -> SplitOptions< 'a, Vec< &'a str > > + { + if self.quoting + { + if self.quoting_prefixes.is_empty() { self.quoting_prefixes = vec![ "\"", "`", "'" ]; } + if self.quoting_postfixes.is_empty() { self.quoting_postfixes = vec![ "\"", "`", "'" ]; } + } + SplitOptions + { + src : self.src, + delimeter : self.delimeter.clone().vector().unwrap(), + preserving_empty : self.preserving_empty, + preserving_delimeters : self.preserving_delimeters, + preserving_quoting : self.preserving_quoting, + stripping : self.stripping, + quoting : self.quoting, + quoting_prefixes : self.quoting_prefixes.clone(), + quoting_postfixes : self.quoting_postfixes.clone(), + } + } + + // Existing perform method + /// Consumes the builder, creates `SplitOptions`, and returns a `SplitIterator` for `Vec<&str>` delimiter. pub fn perform( &mut self ) -> SplitIterator< 'a > { self.form().split() } } + /// Creates a new `SplitOptionsFormer` for configuring string splitting with default options. #[ must_use ] pub fn split< 'a >() -> SplitOptionsFormer< 'a > { SplitOptionsFormer::new( <&str>::default() ) } } -mod_interface_meta::mod_interface! +#[ doc( inline ) ] +#[ allow( unused_imports ) ] +pub use own::*; + +/// Own namespace of the module. +#[ allow( unused_imports ) ] +pub mod own +{ + #[ allow( unused_imports ) ] use super::*; + pub use orphan::*; + pub use private:: + { + Split, + SplitType, + SplitFastIterator, + SplitIterator, + split, + SplitOptionsFormer, + }; +} + +/// Parented namespace of the module. +#[ allow( unused_imports ) ] +pub mod orphan +{ + #[ allow( unused_imports ) ] use super::*; + pub use exposed::*; +} + +/// Exposed namespace of the module. +#[ allow( unused_imports ) ] +pub mod exposed { - exposed use private::Split; - exposed use private::SplitType; - exposed use private::SplitFastIterator; - exposed use private::SplitIterator; - exposed use private::split; - exposed use private::SplitOptionsFormer; + #[ allow( unused_imports ) ] use super::*; + pub use prelude::*; + pub use super::own as split; // Alias for the 'own' module itself + pub use private:: + { + Split, + SplitType, + SplitFastIterator, + SplitIterator, + split, // The function + SplitOptionsFormer, + }; +} + +/// Namespace of the module to include with `use module::*`. +#[ allow( unused_imports ) ] +pub mod prelude +{ + #[ allow( unused_imports ) ] use super::*; + pub use private:: + { + SplitOptionsFormer, + split, + }; } \ No newline at end of file diff --git a/module/core/strs_tools/tests/inc/split_test/indexing_options_tests.rs b/module/core/strs_tools/tests/inc/split_test/indexing_options_tests.rs index 3ec901e128..8f160dca0a 100644 --- a/module/core/strs_tools/tests/inc/split_test/indexing_options_tests.rs +++ b/module/core/strs_tools/tests/inc/split_test/indexing_options_tests.rs @@ -33,7 +33,7 @@ fn test_m_t3_9_mod_index_first() fn test_m_t3_10_mod_index_last() { let src = "abc"; - let mut iter = split() + let iter = split() // Changed from `let mut iter` .src( src ) .delimeter( "b" ) .preserving_empty( false ) diff --git a/module/move/unilang/src/ca/parsing/engine.rs b/module/move/unilang/src/ca/parsing/engine.rs index 337f4d1b28..dd88046034 100644 --- a/module/move/unilang/src/ca/parsing/engine.rs +++ b/module/move/unilang/src/ca/parsing/engine.rs @@ -1,6 +1,6 @@ //! Main parser logic for unilang CLI syntax. -#[allow(unused_imports)] +#[ allow( unused_imports ) ] use super::input::{ InputAbstraction, InputPart, DelimiterType, Location }; use super::instruction::GenericInstruction; use super::error::ParseError; diff --git a/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs index a4504f50c1..9a04eb26ba 100644 --- a/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs +++ b/module/postponed/type_constructor/tests/inc/pair/pair_parametrized_main_manual_test.rs @@ -1,4 +1,4 @@ -#[allow(unused_imports)] +#[ allow( unused_imports ) ] use super::*; //