Use strip_{prefix|suffix}
instead of {starts|ends}_with
+indexing
This commit is contained in:
parent
8b87fefd76
commit
a3e4dff183
7 changed files with 20 additions and 21 deletions
|
@ -390,13 +390,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
if let Some((name, term)) = associated_ty {
|
||||
// FIXME: this case overlaps with code in TyCtxt::note_and_explain_type_err.
|
||||
// That should be extracted into a helper function.
|
||||
if constraint.ends_with('>') {
|
||||
constraint = format!(
|
||||
"{}, {} = {}>",
|
||||
&constraint[..constraint.len() - 1],
|
||||
name,
|
||||
term
|
||||
);
|
||||
if let Some(stripped) = constraint.strip_suffix('>') {
|
||||
constraint = format!("{stripped}, {name} = {term}>");
|
||||
} else {
|
||||
constraint.push_str(&format!("<{name} = {term}>"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue