-
Notifications
You must be signed in to change notification settings - Fork 159
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
[FEAT] Add str.capitalize() function #2003
Conversation
48234aa
to
4fc08bb
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2003 +/- ##
==========================================
- Coverage 84.70% 84.27% -0.44%
==========================================
Files 58 59 +1
Lines 6363 6409 +46
==========================================
+ Hits 5390 5401 +11
- Misses 973 1008 +35
|
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.
Thanks! This looks pretty clean. 🚀 🚀 🚀
Just a few comments and we should be good
src/daft-core/src/array/ops/utf8.rs
Outdated
Some(first) => { | ||
let firstchar = first.to_uppercase(); | ||
let mut res = String::with_capacity(v.len()); | ||
res.extend(firstchar); |
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.
Nit: it seems that firstchar
may actually not be a single character in certain special cases, based on https://doc.rust-lang.org/std/primitive.char.html#method.to_uppercase
Let's rename the firstchar
variable to first_char_uppercased
?
src/daft-core/src/array/ops/utf8.rs
Outdated
let firstchar = first.to_uppercase(); | ||
let mut res = String::with_capacity(v.len()); | ||
res.extend(firstchar); | ||
for c in chars { |
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.
nit: prefer iterator chaining if possible
res.extend(chars.flat_map(|c| c.to_lowercase()))
4fc08bb
to
226b3ee
Compare
@jaychia thanks for the review. Pushed the changes. |
Congrats on first PR!!! 🚀🚀🚀 |
Uppercase the first letter, lowercase the rest.
Resolves #1919