-
Notifications
You must be signed in to change notification settings - Fork 898
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
[unstable option] where_single_line #3359
Comments
Is this supposed to allow multiple bounds on a single line (similar to how function arguments, struct fields etc. are only split if they won't fit on a single line)? Here's an example diff from applying @@ -207,13 +235,11 @@ pub trait Distribution<T> {
/// }
/// ```
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
- where R: Rng, Self: Sized
+ where
+ R: Rng,
+ Self: Sized,
{
- DistIter {
- distr: self,
- rng,
- phantom: ::core::marker::PhantomData,
- }
+ DistIter { distr: self, rng, phantom: ::core::marker::PhantomData }
}
} |
With this option turned on, I think the following change to the fn test_samples<T: SampleUniform + Copy + core::fmt::Debug + PartialEq>(
- lb: T, ub: T, expected_single: &[T], expected_multiple: &[T]
- )
- where Uniform<T>: Distribution<T>
+ lb: T,
+ ub: T,
+ expected_single: &[T],
+ expected_multiple: &[T],
+ ) where
+ Uniform<T>: Distribution<T>,
{ |
I'm also struggling to figure out what this option actually does. I expected these bounds to all be on the same line: impl<S, T, I, O, Ix> Machine for DfaMachine<S, T, I, O, Ix>
-where I: Iterator, O: Iterator, Ix: IndexType,
+where
+ I: Iterator,
+ O: Iterator,
+ Ix: IndexType,
{
type State = S;
type Transition = T;
|
Thank you both for sharing, and apologies @dhardy for missing the prior questions (suspect it got list in the github inbox noise). I'm not sure offhand if the behavior shared above is a bug or if we've simply got spectacularly underspecified docs for the option, but I vaguely remember having a similar thought/question in the past over the formatting of a type alias. |
I've been using this option for a while under the impression that it means: I don't want to speak on behalf of the author, but this is the behavior I've consistently observed from it, I think supporting a 3rd option (that always puts all clauses on one line), and updating the docs might go a long way here. |
I think it would look neater to have it based on length rather than just if there's one, as stacking two pretty short bounds on top of each other looks less than ideal to me. I also wonder how this could interact with brace_style. I would personally want it to be on the same line if the where clause is on a single line, but on the next line of the where clause is expanded |
Is their a time line for this to be stabilized? I greatly prefer this formatting to the default so it would be nice to know. |
Tracking issue for unstable option: where_single_line
The text was updated successfully, but these errors were encountered: