Closed hamirmahal closed 2 weeks ago
This change would clean up functions like this.
fn foo(mut s: String, domain: &str) -> String {
s = s.trim().to_string();
s.push('@');
s.push_str(domain);
s
}
fn foo(mut s: String, domain: &str) -> String {
s = s.trim().to_string();
s.push('@');
s.push_str(domain)
}
If push_str
returns self
, now, it'll be more difficult to change it to something else, later, like self.len()
.
Although I will say that returning self.len()
is worse than returning self
, since it's trivial to get self.len()
given self
, but not the other way around.
Normally a tracking issue is not required for "instantly stable" changes i.e. standard library changes which do not require the user to enable a particular #![feature(...)]
in order to use. push_str
is not behind such a feature gate.
Feature gate:
#![feature(push_str_returns_self)]
This is a tracking issue for
push_str
returningself
.Public API
Steps / History
Unresolved Questions