Skip to content
2 changes: 1 addition & 1 deletion module/alias/willbe2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#[ allow( unused_imports ) ]
use ::willbe2::*;

// fn main() -> Result< (), wtools::error::untyped::Error >
// fn main() -> Result< (), wtools::error::untyped::Error >
// {
// Ok( willbe::run()? )
// }
Expand Down
2 changes: 1 addition & 1 deletion module/alias/wtest/src/test/commands/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl< 'a > SmokeModuleTest< 'a >
self
}

fn form( &mut self ) -> Result< (), &'static str >
fn form( &mut self ) -> Result< (), &'static str >
{
std ::fs ::create_dir( &self.test_path ).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion module/core/asbytes/src/into_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod private
pub use bytemuck :: { Pod };

/// Trait for consuming data into an owned byte vector.
/// This trait is for types that can be meaningfully converted into a `Vec< u8 >`
/// This trait is for types that can be meaningfully converted into a `Vec< u8 >`
/// by consuming the original value.
pub trait IntoBytes {
/// Consumes the value and returns its byte representation as an owned `Vec< u8 >`.
Expand Down
80 changes: 80 additions & 0 deletions module/core/component_model/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,86 @@ impl< T : Into< usize > > Assign< usize, T > for Database
self.pool_size = component.into();
}
}

let config = DatabaseConfig::default()
.impute( "postgres.example.com" ) // String
.impute( 5432 ) // i32
.impute( 30u64 ); // Duration from seconds
```

### HTTP Client Builders
```rust
use component_model::{ ComponentModel, Assign };
use std::time::Duration;

#[ derive( Default, ComponentModel ) ]
struct HttpClient
{
base_url : String,
timeout : Duration,
}

let client = HttpClient::default()
.impute( "https://api.example.com" )
.impute( 30.0f64 ); // Duration from fractional seconds
```

### Game Entity Systems
```rust
use component_model::{ ComponentModel, Assign };

#[ derive( Default, ComponentModel ) ]
struct Player
{
name : String,
level : i32,
}

// Initialize components
let mut player = Player::default();
player.assign( "Hero" );
player.assign( 1 );
```

## 🧪 Examples

Explore the [examples directory](examples/) for comprehensive usage patterns:

- **[`000_basic_assignment.rs`](examples/000_basic_assignment.rs)** - Basic component assignment
- **[`001_fluent_builder.rs`](examples/001_fluent_builder.rs)** - Fluent builder pattern
- **[`002_multiple_components.rs`](examples/002_multiple_components.rs)** - Multiple component handling
- **[`003_component_from.rs`](examples/003_component_from.rs)** - Component creation patterns
- **[`004_working_example.rs`](examples/004_working_example.rs)** - Real-world usage scenarios
- **[`component_model_trivial.rs`](examples/component_model_trivial.rs)** - Minimal example

## 📋 Supported Popular Types

ComponentModel includes built-in intelligent conversion for:

| Type | Input Types | Example |
|------|-------------|---------|
| `Duration` | `u64`, `f64`, `(u64, u32)` | `config.assign( 30u64 )` |
| `PathBuf` | `&str`, `String` | `config.assign( "/path/file" )` |
| `SocketAddr` | *Coming soon* | String parsing planned |
| `HashMap` | *Framework ready* | Vec conversion planned |
| `HashSet` | *Framework ready* | Vec conversion planned |

## ⚠️ Important Limitations

**Type Ambiguity**: When a struct has multiple fields of the same type, `assign()` becomes ambiguous and won't compile. This is by design for type safety.

```rust
# use component_model::{ ComponentModel, Assign };
# #[ derive( Default, ComponentModel ) ]
struct Config
{
host : String,
database : String, // Multiple String fields cause ambiguity
}

// This won't compile due to ambiguity:
// let mut config = Config::default();
// config.assign( "localhost" ); // Error: which String field?
```

## 📚 Available Derive Macros
Expand Down
118 changes: 118 additions & 0 deletions module/core/component_model_meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,121 @@ pub fn component_model(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
Err(err) => err.to_compile_error().into(),
}
}

/// Unified derive macro that combines all component model functionality into a single annotation.
///
/// The `ComponentModel` derive automatically generates implementations for:
/// - `Assign`: Basic component assignment with type-safe field setting
/// - `ComponentsAssign`: Multiple component assignment from tuples (when applicable)
/// - `ComponentFrom`: Create objects from single components (when applicable)
/// - `FromComponents`: Create objects from multiple components (when applicable)
///
/// This eliminates the need to apply multiple individual derives and reduces boilerplate.
///
/// # Features
///
/// - Requires the `derive_component_model` feature to be enabled for use.
/// - Automatically detects which trait implementations are appropriate for the struct.
/// - Handles type conflicts gracefully by skipping conflicting implementations.
///
/// # Attributes
///
/// - `debug` : Optional attribute to enable debug-level output during macro expansion.
/// - `component` : Optional field-level attribute for customizing component behavior.
///
/// # Examples
///
/// ```rust
/// use component_model_meta::ComponentModel;
/// use component_model_types::Assign;
///
/// #[ derive( Default, ComponentModel ) ]
/// struct Config
/// {
/// host : String,
/// port : i32,
/// enabled : bool,
/// }
///
/// let mut config = Config::default();
///
/// // Use Assign trait (auto-generated)
/// config.assign( "localhost".to_string() );
/// config.assign( 8080i32 );
/// config.enabled_set( true ); // Use field-specific method to avoid type ambiguity
///
/// // Use fluent builder pattern (auto-generated)
/// let config2 = Config::default()
/// .impute( "api.example.com".to_string() )
/// .impute( 3000i32 )
/// .enabled_with( false ); // Use field-specific method to avoid type ambiguity
/// ```
#[ cfg( feature = "enabled" ) ]
#[ cfg( feature = "derive_component_model" ) ]
#[proc_macro_derive(ComponentModel, attributes(debug, component))]
pub fn component_model(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let result = component::component_model::component_model(input);
match result {
Ok(stream) => stream.into(),
Err(err) => err.to_compile_error().into(),
}
}

/// Unified derive macro that combines all component model functionality into a single annotation.
///
/// The `ComponentModel` derive automatically generates implementations for:
/// - `Assign`: Basic component assignment with type-safe field setting
/// - `ComponentsAssign`: Multiple component assignment from tuples (when applicable)
/// - `ComponentFrom`: Create objects from single components (when applicable)
/// - `FromComponents`: Create objects from multiple components (when applicable)
///
/// This eliminates the need to apply multiple individual derives and reduces boilerplate.
///
/// # Features
///
/// - Requires the `derive_component_model` feature to be enabled for use.
/// - Automatically detects which trait implementations are appropriate for the struct.
/// - Handles type conflicts gracefully by skipping conflicting implementations.
///
/// # Attributes
///
/// - `debug` : Optional attribute to enable debug-level output during macro expansion.
/// - `component` : Optional field-level attribute for customizing component behavior.
///
/// # Examples
///
/// ```rust
/// use component_model_meta::ComponentModel;
/// use component_model_types::Assign;
///
/// #[ derive( Default, ComponentModel ) ]
/// struct Config
/// {
/// host : String,
/// port : i32,
/// enabled : bool,
/// }
///
/// let mut config = Config::default();
///
/// // Use Assign trait (auto-generated)
/// config.assign( "localhost".to_string() );
/// config.assign( 8080i32 );
/// config.enabled_set( true ); // Use field-specific method to avoid type ambiguity
///
/// // Use fluent builder pattern (auto-generated)
/// let config2 = Config::default()
/// .impute( "api.example.com".to_string() )
/// .impute( 3000i32 )
/// .enabled_with( false ); // Use field-specific method to avoid type ambiguity
/// ```
#[ cfg( feature = "enabled" ) ]
#[ cfg( feature = "derive_component_model" ) ]
#[proc_macro_derive(ComponentModel, attributes(debug, component))]
pub fn component_model(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let result = component::component_model::component_model(input);
match result {
Ok(stream) => stream.into(),
Err(err) => err.to_compile_error().into(),
}
}
2 changes: 1 addition & 1 deletion module/core/component_model_types/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub trait Assign< T, IntoT >
/// }
/// }
///
/// let mut opt_struct: Option< MyStruct > = None;
/// let mut opt_struct: Option< MyStruct > = None;
/// opt_struct.option_assign( MyStruct { name: "New Name".to_string() } );
/// assert_eq!( opt_struct.unwrap().name, "New Name" );
/// ```
Expand Down
48 changes: 48 additions & 0 deletions module/core/diagnostics_tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,54 @@ serde_json = "1.0"



[[example]]
name = "001_basic_runtime_assertions"
required-features = ["enabled"]

[[example]]
name = "002_better_error_messages"
required-features = ["enabled"]

[[example]]
name = "003_compile_time_checks"
required-features = ["enabled"]

[[example]]
name = "004_memory_layout_validation"
required-features = ["enabled"]

[[example]]
name = "005_debug_variants"
required-features = ["enabled"]

[[example]]
name = "006_real_world_usage"
required-features = ["enabled"]

[[example]]
name = "001_basic_runtime_assertions"
required-features = ["enabled"]

[[example]]
name = "002_better_error_messages"
required-features = ["enabled"]

[[example]]
name = "003_compile_time_checks"
required-features = ["enabled"]

[[example]]
name = "004_memory_layout_validation"
required-features = ["enabled"]

[[example]]
name = "005_debug_variants"
required-features = ["enabled"]

[[example]]
name = "006_real_world_usage"
required-features = ["enabled"]

[[example]]
name = "001_basic_runtime_assertions"
required-features = ["enabled"]
Expand Down
2 changes: 1 addition & 1 deletion module/core/format_tools/src/format/as_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ mod private
}

// impl< Row > IntoAsTable
// for Vec< Row >
// for Vec< Row >
// where
// Row: Cells< Self ::CellKey >,
// // CellKey: table ::CellKey + ?Sized,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Hash for TestObjectWithoutImpl
impl PartialOrd for TestObjectWithoutImpl
{

fn partial_cmp( &self, other: &Self ) -> Option< Ordering >
fn partial_cmp( &self, other: &Self ) -> Option< Ordering >
{
Some( self.cmp( other ) )
}
Expand All @@ -116,7 +116,7 @@ impl Ord for TestObjectWithoutImpl
}

/// Generate a dynamic array of test objects.
pub fn test_objects_gen() -> Vec< TestObjectWithoutImpl >
pub fn test_objects_gen() -> Vec< TestObjectWithoutImpl >
{

vec!
Expand Down
2 changes: 1 addition & 1 deletion module/core/format_tools/src/format/text_wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mod private
/// too literally. That is why `wrap_width` is introduced, and additional spaces to the
/// right side should be included by the output formatter.
#[ derive( Debug ) ]
pub struct WrappedCell< 'data >
pub struct WrappedCell< 'data >
{
/// Width of the cell. In calculations use this width instead of slice length in order
/// to properly center the text. See example in the doc string of the parent struct.
Expand Down
25 changes: 25 additions & 0 deletions module/core/former/task/002_fix_collection_former_btree_map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Fix collection_former_btree_map Test

## Issue
Test is disabled due to: "Complex collection type mismatch issues with subform"

## Files Involved
- `/home/user1/pro/lib/wTools/module/core/former/tests/inc/struct_tests/collection_former_btree_map.rs`
- `/home/user1/pro/lib/wTools/module/core/former/tests/inc/struct_tests/mod.rs` (line 143)

## Problem Description
The subformer test in this file (lines 160-195) has Former derives commented out due to complex collection type mismatch issues.

## Investigation Required
1. Examine the subformer function that uses BTreeMap with subform_collection
2. Identify the specific type mismatch between Parent and Child formers
3. Determine if it's related to BTreeMapDefinition handling

## Expected Outcome
Enable the Former derives and get the subformer test working with BTreeMap collections.

## Priority
Medium - BTreeMap is a standard collection that should work with subforms

## Status
Blocked - requires investigation
Loading
Loading