-
Notifications
You must be signed in to change notification settings - Fork 13.9k
implement replace_with
and replacen_with
for unstable feature replace_with
#147741
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
base: master
Are you sure you want to change the base?
Conversation
if let Some(from_byte) = match from.as_utf8_pattern() { | ||
Some(Utf8Pattern::StringPattern([from_byte])) => Some(*from_byte), | ||
Some(Utf8Pattern::CharPattern(c)) => c.as_ascii().map(|ascii_char| ascii_char.to_u8()), | ||
_ => None, | ||
} { | ||
if let Some(sref) = from_byte.as_ascii().map(|ascii_char| f(ascii_char.as_str())) { | ||
if let [to_byte] = sref.as_ref().as_bytes() { | ||
return unsafe { replace_ascii(self.as_bytes(), from_byte, *to_byte) }; | ||
} | ||
} | ||
} |
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.
Would it be possible to use let chains here?
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.
Updated with an if-let chain, did you have something else in mind or is this fine? (f70b5e1)
This comment has been minimized.
This comment has been minimized.
Hm, that's weird because alloc is 2024 edition Line 11 in f524236
|
It does compile with edition 2021 anyway tho
Well, I guess that's fine to revert this then :) If this ever will get 2024 edition I will cleanup this accordingly |
This is the PR for the tracking issue #147731 for implementation of
replace_with
.