-
Notifications
You must be signed in to change notification settings - Fork 6
[ISSUE #68]Change from pub fn to pub const fn for from_static_str method
#69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…r` method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Changes the from_static_str method from a regular public function to a const function, allowing it to be evaluated at compile time.
- Modified function declaration to use
pub const fninstead ofpub fn
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
WalkthroughChanged CheetahString::from_static_str from a regular function to a const function in two impl locations, updating the signature to pub const fn from_static_str(s: &'static str) -> Self. No other logic or control flow changes. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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/cheetah_string.rs (1)
230-234: Add a const-context test for from_static_strThe change correctly makes
from_static_straconst fn(it only constructs a struct from a&'static str). No existing tests exercise this in a const context—add one, for example:const CS: CheetahString = CheetahString::from_static_str("hello"); #[test] fn const_from_static_str() { assert_eq!(CS.as_str(), "hello"); }Update the summary to note only a single
const fnaddition, not two locations.
close #68
Summary by CodeRabbit