Skip to content

Conversation

@ginnyTheCat
Copy link

@ginnyTheCatginnyTheCat commented Nov 3, 2025

This is done to allow iterating the results multiple times without needing to redo the lookup step. The std also provides this for ToUppercase and ToLowercase.

Summary by CodeRabbit

  • Enhancements
    • The title case iterator is now cloneable, allowing users to duplicate and reuse title case conversion iterators for multiple operations.

@coderabbitai
Copy link

coderabbitaibot commented Nov 3, 2025

Walkthrough

The pull request adds Clone derivation to two iterator-related types in the crate: CaseMappingIter with two new variants (One, Zero), and ToTitlecase wrapper struct, enabling both internal and public iterator types to be cloned.

Changes

Cohort / File(s)Summary
Iterator cloneability
src/lib.rs
Added #[derive(Clone)] to CaseMappingIter with new variants One and Zero for shorter or empty mapping sequences; added #[derive(Clone)] to public ToTitlecase wrapper struct

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that the new One and Zero variants are properly integrated into existing pattern matching or enum handling logic
  • Confirm that all fields in both types are actually cloneable (no interior mutability or non-Clone dependencies)
  • Check that adding Clone doesn't introduce unintended copies or performance regressions in hot paths

Poem

A rabbit hops with glee, clone, clone, clone
Now iterators dance, no longer alone!
With One and with Zero, the mapping takes flight,
ToTitlecase copies itself, oh what a delight! 🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe pull request title 'Implement Clone for ToTitlecase iterator' accurately describes the main change in the changeset. The PR introduces #[derive(Clone)] for the ToTitlecase struct (the public iterator wrapper) and adds necessary variants to CaseMappingIter to support cloneability. The title is concise, specific, and clearly communicates the primary objective without unnecessary noise or vague terms.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/lib.rs (1)

49-55: Good addition - enables cloning the iterator state.

Deriving Clone for CaseMappingIter is correct since all variants contain only char types, which are Copy. This allows the iterator to be cloned at any point during iteration, creating an independent iterator at the same state.

Consider adding a test to verify the Clone functionality works as expected:

#[test]fntest_to_titlecase_clone(){letmut iter1 = 'ß'.to_titlecase();assert_eq!(iter1.next(),Some('S'));letmut iter2 = iter1.clone();// Both iterators should independently produce the remaining characterassert_eq!(iter1.next(),Some('s'));assert_eq!(iter2.next(),Some('s'));assert_eq!(iter1.next(),None);assert_eq!(iter2.next(),None);}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b1930b and e303116.

📒 Files selected for processing (1)
  • src/lib.rs (2 hunks)
🔇 Additional comments (1)
src/lib.rs (1)

92-93: Excellent - brings API parity with Rust standard library.

Adding Clone to the public ToTitlecase struct is a valuable improvement that aligns with Rust's standard library iterators (ToUppercase and ToLowercase). This allows users to clone the iterator and reuse the titlecase mapping without repeating the lookup operation.

@ginnyTheCat
Copy link
Author

CaseMappingIter with new variants One and Zero

This is just a blatant lie.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@ginnyTheCat