Skip to content

New option to style + in where bounds #4979

@Iron-E

Description

@Iron-E

Coming from #4941. In that issue I suggested that binop_separator be used to control situations such as the following:

pub async fn retrieve_views<'err, E, L, O, P>() -> DynResult<'err, Vec<EmployeeView>>
where
	<E as EmployeeAdapter>::Error: 'err
		+ From<<L as LocationAdapter>::Error>
		+ From<<O as OrganizationAdapter>::Error>
		+ From<<P as PersonAdapter>::Error>
		+ Send,
{

On the above, @calebcartwright said:

Thanks for sharing this observation but binop_separator is by design only applicable to binary expressions, and does not apply to compound constraints regardless of the fact that the latter utilizes one of the same symbols.

[…] If you'd like to have a new config option that could be used to control that behavior in bounds then please open a new issue and we'll take that through the standard process to consider new options.

…which makes sense. However, it leaves rustfmt without a way to configure how constraints are formatted, whereas there are similar options for other contexts (i.e. binop_separator). I personally think this should be configurable, as setting binop_separator to "Back" in a project leaves +-signs at the front in only this case.

I would propose that this new option have the same "Front" and "Back" values available in order to maintain a consistent style across projects.

Thanks for your consideration!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: a feature request (not decided/implemented)P-lowLow priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions