Use strip_{prefix|suffix} instead of {starts|ends}_with+indexing
This commit is contained in:
@@ -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}>"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user