Skip to content

Commit d77dcdf

Browse files
Wandalenclaude
andcommitted
Merge branch 'misuse_1' into cleaning_2: Resolve standalone.rs conflicts
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
2 parents 8fd3e48 + 80fb1cf commit d77dcdf

File tree

75 files changed

+5159
-1248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5159
-1248
lines changed

module/core/test_tools/src/behavioral_equivalence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ mod private {
152152
#[cfg(feature = "standalone_build")]
153153
{
154154
// Placeholder for standalone mode - macros may not be fully available
155-
return Ok(());
155+
Ok(())
156156
}
157157

158158
// COMMENTED OUT: collection_tools dependency disabled to break circular dependencies

module/core/test_tools/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ pub use test::process;
411411
///
412412
/// ## Historical Context
413413
/// This resolves the vec! ambiguity issue while preserving Task 002's macro accessibility.
414+
#[ cfg( feature = "enabled" ) ]
415+
#[ allow( unused_imports ) ]
416+
pub use ::{};
417+
414418
// COMMENTED OUT: error_tools dependency disabled to break circular dependencies
415419
// #[ cfg( feature = "enabled" ) ]
416420
// #[cfg(not(all(feature = "standalone_build", not(feature = "normal_build"))))]
@@ -423,10 +427,6 @@ pub use test::process;
423427
// #[cfg(all(feature = "standalone_build", not(feature = "normal_build")))]
424428
// pub use implsindex as impls_index;
425429

426-
#[ cfg( feature = "enabled" ) ]
427-
#[ allow( unused_imports ) ]
428-
pub use ::{};
429-
430430
/// Verifies that the API stability facade is functioning correctly.
431431
/// This function can be used to check that all stability mechanisms are operational.
432432
#[ cfg( feature = "enabled" ) ]

module/core/test_tools/src/standalone.rs

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,19 @@ pub mod error_tools {
6363
/// The error type for this implementation
6464
type Error;
6565
/// Add context to an error using a closure
66+
///
67+
/// # Errors
68+
///
69+
/// Returns an error if the original operation failed, wrapped with contextual information.
6670
fn err_with<F>(self, f: F) -> Result<T, (String, Self::Error)>
6771
where
6872
Self: Sized,
6973
F: FnOnce() -> String;
7074
/// Add context to an error using a static string
75+
///
76+
/// # Errors
77+
///
78+
/// Returns an error if the original operation failed, wrapped with the provided report message.
7179
fn err_with_report(self, report: &str) -> Result<T, (String, Self::Error)> where Self: Sized;
7280
}
7381

@@ -125,18 +133,43 @@ pub mod error_tools {
125133

126134
/// Collection tools for standalone mode
127135
pub mod collection_tools {
128-
use std::hash::Hash;
136+
use core::hash::Hash;
129137
use std::collections::hash_map::RandomState;
130138

131139
/// A hash map implementation using hashbrown for standalone mode
132140
#[derive(Debug, Clone)]
133141
pub struct HashMap<K, V>(hashbrown::HashMap<K, V, RandomState>);
134142

143+
impl<'a, K, V> IntoIterator for &'a HashMap<K, V>
144+
where
145+
K: Hash + Eq,
146+
{
147+
type Item = (&'a K, &'a V);
148+
type IntoIter = hashbrown::hash_map::Iter<'a, K, V>;
149+
150+
fn into_iter(self) -> Self::IntoIter {
151+
self.iter()
152+
}
153+
}
154+
155+
impl<'a, K, V> IntoIterator for &'a mut HashMap<K, V>
156+
where
157+
K: Hash + Eq,
158+
{
159+
type Item = (&'a K, &'a mut V);
160+
type IntoIter = hashbrown::hash_map::IterMut<'a, K, V>;
161+
162+
fn into_iter(self) -> Self::IntoIter {
163+
self.iter_mut()
164+
}
165+
}
166+
135167
impl<K, V> HashMap<K, V>
136168
where
137169
K: Hash + Eq,
138170
{
139171
/// Create a new empty `HashMap`
172+
#[must_use]
140173
pub fn new() -> Self {
141174
Self(hashbrown::HashMap::with_hasher(RandomState::new()))
142175
}
@@ -149,21 +182,28 @@ pub mod collection_tools {
149182
/// Get a reference to the value for a given key
150183
pub fn get<Q>(&self, k: &Q) -> Option<&V>
151184
where
152-
K: std::borrow::Borrow<Q>,
185+
K: core::borrow::Borrow<Q>,
153186
Q: Hash + Eq + ?Sized,
154187
{
155188
self.0.get(k)
156189
}
157190

158191
/// Get the number of elements in the `HashMap`
192+
#[must_use]
159193
pub fn len(&self) -> usize {
160194
self.0.len()
161195
}
162196

197+
/// Returns true if the `HashMap` is empty
198+
#[must_use]
199+
pub fn is_empty(&self) -> bool {
200+
self.0.is_empty()
201+
}
202+
163203
/// Get a mutable reference to the value for a given key
164204
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
165205
where
166-
K: std::borrow::Borrow<Q>,
206+
K: core::borrow::Borrow<Q>,
167207
Q: Hash + Eq + ?Sized,
168208
{
169209
self.0.get_mut(k)
@@ -172,18 +212,19 @@ pub mod collection_tools {
172212
/// Remove a key-value pair from the `HashMap`
173213
pub fn remove<Q>(&mut self, k: &Q) -> Option<V>
174214
where
175-
K: std::borrow::Borrow<Q>,
215+
K: core::borrow::Borrow<Q>,
176216
Q: Hash + Eq + ?Sized,
177217
{
178218
self.0.remove(k)
179219
}
180220

181221
/// Clear all key-value pairs from the `HashMap`
182222
pub fn clear(&mut self) {
183-
self.0.clear()
223+
self.0.clear();
184224
}
185225

186226
/// Returns an iterator over all key-value pairs (immutable references)
227+
#[must_use]
187228
pub fn iter(&self) -> hashbrown::hash_map::Iter<'_, K, V> {
188229
self.0.iter()
189230
}
@@ -277,13 +318,28 @@ pub mod collection_tools {
277318

278319
impl<T: core::hash::Hash + Eq> Eq for HashSet<T> {}
279320

321+
impl<'a, T> IntoIterator for &'a HashSet<T>
322+
where
323+
T: Hash + Eq,
324+
{
325+
type Item = &'a T;
326+
type IntoIter = hashbrown::hash_set::Iter<'a, T>;
327+
328+
fn into_iter(self) -> Self::IntoIter {
329+
self.iter()
330+
}
331+
}
332+
280333
impl<T> HashSet<T> {
281334
/// Create a new empty `HashSet`
335+
#[must_use]
282336
pub fn new() -> Self {
283337
Self(hashbrown::HashSet::with_hasher(RandomState::new()))
284338
}
285339

286340
/// Returns an iterator over the set
341+
#[must_use]
342+
#[allow(clippy::iter_without_into_iter)]
287343
pub fn iter(&self) -> hashbrown::hash_set::Iter<'_, T> {
288344
self.0.iter()
289345
}
@@ -297,11 +353,13 @@ pub mod collection_tools {
297353
}
298354

299355
/// Returns the number of elements in the set
356+
#[must_use]
300357
pub fn len(&self) -> usize {
301358
self.0.len()
302359
}
303360

304361
/// Returns true if the set is empty
362+
#[must_use]
305363
pub fn is_empty(&self) -> bool {
306364
self.0.is_empty()
307365
}
@@ -628,7 +686,6 @@ pub mod collection_tools {
628686
}
629687
// Collection tools re-exported at crate level
630688
#[allow(unused_imports)]
631-
632689
/// Memory tools for standalone mode
633690
pub mod mem_tools {
634691
use core::ptr;
@@ -655,8 +712,8 @@ pub mod mem_tools {
655712
}
656713

657714
// Check if they're the exact same memory location
658-
let ptr1 = std::ptr::from_ref(src1).cast::<()>();
659-
let ptr2 = std::ptr::from_ref(src2).cast::<()>();
715+
let ptr1 = core::ptr::from_ref(src1).cast::<()>();
716+
let ptr2 = core::ptr::from_ref(src2).cast::<()>();
660717
ptr1 == ptr2
661718
}
662719

@@ -686,7 +743,6 @@ pub mod mem_tools {
686743
}
687744
// Memory tools re-exported at crate level
688745
#[allow(unused_imports)]
689-
690746
/// Typing tools for standalone mode
691747
pub mod typing_tools {
692748
// Minimal typing utilities for standalone mode
@@ -1247,7 +1303,7 @@ macro_rules! is_slice {
12471303
#[macro_export]
12481304
macro_rules! debug_assert_id_macro {
12491305
($left:expr, $right:expr) => {
1250-
crate::debug_assert_id($left, $right);
1306+
$crate::debug_assert_id($left, $right);
12511307
};
12521308
}
12531309

module/move/benchkit/examples/cargo_bench_integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ my_rust_project/
275275
println!(r#"
276276
[package]
277277
name = "my_rust_project"
278-
version = "0.1.0"
278+
version = "0.8.0"
279279
280280
# Standard Rust benchmark configuration
281281
[[bench]]
@@ -287,7 +287,7 @@ name = "algorithm_comparison"
287287
harness = false
288288
289289
[dev-dependencies]
290-
benchkit = {{ version = "0.1", features = ["cargo_bench", "regression_analysis"] }}
290+
benchkit = {{ version = "0.8.0", features = ["cargo_bench", "regression_analysis"] }}
291291
292292
[features]
293293
# Optional: allow disabling benchmarks in some environments

module/move/benchkit/readme.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
`benchkit` is a lightweight toolkit for performance analysis, born from the hard-learned lessons of optimizing high-performance libraries. It rejects rigid, all-or-nothing frameworks in favor of flexible, composable tools that integrate seamlessly into your existing workflow.
99

10-
> 🎯 **NEW TO benchkit?** Start with [`recommendations.md`](recommendations.md) - Essential guidelines from real-world performance optimization experience.
10+
> 🎯 **NEW TO benchkit?** Start with [`usage.md`](usage.md) - Mandatory standards and requirements from production systems.
1111
1212
## The Benchmarking Dilemma
1313

@@ -18,7 +18,7 @@ In Rust, developers often face a frustrating choice:
1818

1919
`benchkit` offers a third way.
2020

21-
> **📋 Important**: For production use and development contributions, see [`recommendations.md`](recommendations.md) - a comprehensive guide with proven patterns, requirements, and best practices from real-world benchmarking experience.
21+
> **📋 Important**: For production use and development contributions, see [`usage.md`](usage.md) - mandatory standards with proven patterns, requirements, and compliance standards from production systems.
2222
2323
## A Toolkit, Not a Framework
2424

@@ -33,14 +33,14 @@ This is the core philosophy of `benchkit`. It doesn't impose a workflow; it prov
3333

3434
## 🚀 Quick Start: Compare, Analyze, and Document
3535

36-
**📖 First time?** Review [`recommendations.md`](recommendations.md) for comprehensive best practices and development guidelines.
36+
**📖 First time?** Review [`usage.md`](usage.md) for mandatory compliance standards and development requirements.
3737

3838
This example demonstrates the core `benchkit` workflow: comparing two algorithms and automatically updating a performance section in your `readme.md`.
3939

4040
**1. Add to `dev-dependencies` in `Cargo.toml`:**
4141
```toml
4242
[dev-dependencies]
43-
benchkit = { version = "0.1", features = [ "full" ] }
43+
benchkit = { version = "0.8.0", features = [ "full" ] }
4444
```
4545

4646
**2. Create a benchmark in your `benches` directory:**
@@ -910,7 +910,7 @@ Add to your `Cargo.toml`:
910910
benchmark = ["benchkit"]
911911

912912
[dev-dependencies]
913-
benchkit = { version = "0.1", features = ["full"], optional = true }
913+
benchkit = { version = "0.8.0", features = ["full"], optional = true }
914914
```
915915

916916
Run benchmarks selectively:
@@ -1053,12 +1053,12 @@ Add `benchkit` to your `[dev-dependencies]` in `Cargo.toml`.
10531053
benchkit = "0.1"
10541054

10551055
# Or enable all features for the full toolkit
1056-
benchkit = { version = "0.1", features = [ "full" ] }
1056+
benchkit = { version = "0.8.0", features = [ "full" ] }
10571057
```
10581058

10591059
## 📋 Development Guidelines & Best Practices
10601060

1061-
**⚠️ IMPORTANT**: Before using benchkit in production or contributing to development, **strongly review** the comprehensive [`recommendations.md`](recommendations.md) file. This document contains essential requirements, best practices, and lessons learned from real-world performance analysis work.
1061+
**⚠️ IMPORTANT**: Before using benchkit in production or contributing to development, **strongly review** the comprehensive [`usage.md`](usage.md) file. This document contains essential requirements, best practices, and lessons learned from real-world performance analysis work.
10621062

10631063
The recommendations cover:
10641064
-**Core philosophy** and toolkit vs framework principles
@@ -1067,18 +1067,18 @@ The recommendations cover:
10671067
-**Documentation integration** requirements for automated reporting
10681068
-**Statistical analysis** requirements for reliable measurements
10691069

1070-
**📖 Read [`recommendations.md`](recommendations.md) first** - it will save you time and ensure you're following proven patterns.
1070+
**📖 Read [`usage.md`](usage.md) first** - it will save you time and ensure you're following proven patterns.
10711071

10721072
## Contributing
10731073

10741074
Contributions are welcome! `benchkit` aims to be a community-driven toolkit that solves real-world benchmarking problems.
10751075

10761076
**Before contributing:**
1077-
1. **📖 Read [`recommendations.md`](recommendations.md)** - Contains all development requirements and design principles
1077+
1. **📖 Read [`usage.md`](usage.md)** - Contains all development requirements and design principles
10781078
2. Review open tasks in the [`task/`](task/) directory
10791079
3. Check our contribution guidelines
10801080

1081-
All contributions must align with the principles and requirements outlined in [`recommendations.md`](recommendations.md).
1081+
All contributions must align with the principles and requirements outlined in [`usage.md`](usage.md).
10821082

10831083
## License
10841084

module/move/benchkit/roadmap.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,6 @@ fn compare_algorithms() {
315315
## References
316316

317317
- **spec.md** - Complete functional requirements and technical specifications
318-
- **recommendations.md** - Lessons learned from unilang/strs_tools benchmarking
318+
- **usage.md** - Lessons learned from unilang/strs_tools benchmarking
319319
- **Design Rulebook** - Architectural principles and development procedures
320320
- **Codestyle Rulebook** - Code formatting and structural patterns

module/move/benchkit/spec.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ fn research_grade_performance_analysis()
614614

615615
### 12. Lessons Learned Reference
616616

617-
**CRITICAL**: All development decisions for benchkit are based on real-world experience from unilang and strs_tools benchmarking work. The complete set of requirements, anti-patterns, and lessons learned is documented in [`recommendations.md`](recommendations.md).
617+
**CRITICAL**: All development decisions for benchkit are based on real-world experience from unilang and strs_tools benchmarking work. The complete set of requirements, anti-patterns, and mandatory standards is documented in [`usage.md`](usage.md).
618618

619619
**Key lessons that shaped benchkit design:**
620620

@@ -650,7 +650,7 @@ fn research_grade_performance_analysis()
650650
- **Solution**: Exact matching with `line.trim() == section_marker.trim()` + API validation
651651
- **Prevention**: Safe API with conflict detection, comprehensive regression tests, backwards compatibility
652652

653-
**For complete requirements and anti-patterns, see [`recommendations.md`](recommendations.md).**
653+
**For complete requirements and mandatory standards, see [`usage.md`](usage.md).**
654654

655655
### 13. Cargo Bench Integration Requirements ⭐ **CRITICAL**
656656

@@ -673,7 +673,7 @@ name = "performance_suite"
673673
harness = false # Use benchkit as the harness
674674

675675
[dev-dependencies]
676-
benchkit = { version = "0.1", features = ["cargo_bench"] }
676+
benchkit = { version = "0.8.0", features = ["cargo_bench"] }
677677
```
678678

679679
```rust
@@ -774,6 +774,6 @@ Based on real-world usage patterns and critical path analysis from unilang/strs_
774774

775775
### Reference Documents
776776

777-
- **[`recommendations.md`](recommendations.md)** - Complete requirements from real-world experience
777+
- **[`usage.md`](usage.md)** - Mandatory standards and compliance requirements from production systems
778778
- **[`readme.md`](readme.md)** - Usage-focused documentation with examples
779779
- **[`examples/`](examples/)** - Comprehensive usage demonstrations

module/move/benchkit/src/templates.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ impl PerformanceReport
819819
{
820820
// Fallback to placeholder when no historical data available
821821
output.push_str( "**Regression Analysis**: Not yet implemented. Historical baseline data required.\n\n" );
822-
output.push_str( "**📖 Setup Guide**: See [`recommendations.md`](recommendations.md) for comprehensive guidelines on:\n" );
822+
output.push_str( "**📖 Setup Guide**: See [`usage.md`](usage.md) for mandatory standards and requirements on:\n" );
823823
output.push_str( "- Historical data collection and baseline management\n" );
824824
output.push_str( "- Statistical analysis requirements and validation criteria\n" );
825825
output.push_str( "- Integration with CI/CD pipelines for automated regression detection\n" );

0 commit comments

Comments
 (0)