Skip to content

Commit 59c9fb3

Browse files
authored
Merge pull request #442 from mgeisler/revert-single-expr-functions
Revert "Put single-expression functions on a single line"
2 parents 265ba9a + 99154ae commit 59c9fb3

File tree

8 files changed

+38
-12
lines changed

8 files changed

+38
-12
lines changed

fuzz/fuzz_targets/wrap_first_fit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct Word {
1111
penalty_width: f64,
1212
}
1313

14+
#[rustfmt::skip]
1415
impl core::Fragment for Word {
1516
fn width(&self) -> f64 { self.width }
1617
fn whitespace_width(&self) -> f64 { self.whitespace_width }

fuzz/fuzz_targets/wrap_optimal_fit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct Word {
3232
penalty_width: f64,
3333
}
3434

35+
#[rustfmt::skip]
3536
impl core::Fragment for Word {
3637
fn width(&self) -> f64 { self.width }
3738
fn whitespace_width(&self) -> f64 { self.whitespace_width }

fuzz/fuzz_targets/wrap_optimal_fit_usize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct Word {
3232
penalty_width: usize,
3333
}
3434

35+
#[rustfmt::skip]
3536
impl core::Fragment for Word {
3637
fn width(&self) -> f64 { self.width as f64 }
3738
fn whitespace_width(&self) -> f64 { self.whitespace_width as f64 }

rustfmt.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
fn_single_line = true
21
imports_granularity = "Module"

src/core.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ pub(crate) fn skip_ansi_escape_sequence<I: Iterator<Item = char>>(ch: char, char
6161

6262
#[cfg(feature = "unicode-width")]
6363
#[inline]
64-
fn ch_width(ch: char) -> usize { unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0) }
64+
fn ch_width(ch: char) -> usize {
65+
unicode_width::UnicodeWidthChar::width(ch).unwrap_or(0)
66+
}
6567

6668
/// First character which [`ch_width`] will classify as double-width.
6769
/// Please see [`display_width`].
@@ -224,7 +226,9 @@ pub struct Word<'a> {
224226
impl std::ops::Deref for Word<'_> {
225227
type Target = str;
226228

227-
fn deref(&self) -> &Self::Target { self.word }
229+
fn deref(&self) -> &Self::Target {
230+
self.word
231+
}
228232
}
229233

230234
impl<'a> Word<'a> {
@@ -299,17 +303,23 @@ impl<'a> Word<'a> {
299303

300304
impl Fragment for Word<'_> {
301305
#[inline]
302-
fn width(&self) -> f64 { self.width as f64 }
306+
fn width(&self) -> f64 {
307+
self.width as f64
308+
}
303309

304310
// We assume the whitespace consist of ' ' only. This allows us to
305311
// compute the display width in constant time.
306312
#[inline]
307-
fn whitespace_width(&self) -> f64 { self.whitespace.len() as f64 }
313+
fn whitespace_width(&self) -> f64 {
314+
self.whitespace.len() as f64
315+
}
308316

309317
// We assume the penalty is `""` or `"-"`. This allows us to
310318
// compute the display width in constant time.
311319
#[inline]
312-
fn penalty_width(&self) -> f64 { self.penalty.len() as f64 }
320+
fn penalty_width(&self) -> f64 {
321+
self.penalty.len() as f64
322+
}
313323
}
314324

315325
/// Forcibly break words wider than `line_width` into smaller words.

src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ impl<'a> From<&'a Options<'a>> for Options<'a> {
273273
}
274274

275275
impl<'a> From<usize> for Options<'a> {
276-
fn from(width: usize) -> Self { Options::new(width) }
276+
fn from(width: usize) -> Self {
277+
Options::new(width)
278+
}
277279
}
278280

279281
impl<'a> Options<'a> {
@@ -340,7 +342,9 @@ impl<'a> Options<'a> {
340342
/// **Note:** Only available when the `terminal_size` feature is
341343
/// enabled.
342344
#[cfg(feature = "terminal_size")]
343-
pub fn with_termwidth() -> Self { Self::new(termwidth()) }
345+
pub fn with_termwidth() -> Self {
346+
Self::new(termwidth())
347+
}
344348
}
345349

346350
impl<'a> Options<'a> {
@@ -1837,5 +1841,7 @@ mod tests {
18371841

18381842
#[test]
18391843
#[should_panic]
1840-
fn wrap_columns_panic_with_zero_columns() { wrap_columns("", 0, 10, "", "", ""); }
1844+
fn wrap_columns_panic_with_zero_columns() {
1845+
wrap_columns("", 0, 10, "", "", "");
1846+
}
18411847
}

src/wrap_algorithms.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ impl WrapAlgorithm {
122122
/// **Note:** Only available when the `smawk` Cargo feature is
123123
/// enabled.
124124
#[cfg(feature = "smawk")]
125-
pub const fn new_optimal_fit() -> Self { WrapAlgorithm::OptimalFit(Penalties::new()) }
125+
pub const fn new_optimal_fit() -> Self {
126+
WrapAlgorithm::OptimalFit(Penalties::new())
127+
}
126128

127129
/// Wrap words according to line widths.
128130
///
@@ -157,7 +159,9 @@ impl WrapAlgorithm {
157159
}
158160

159161
impl Default for WrapAlgorithm {
160-
fn default() -> Self { WrapAlgorithm::new() }
162+
fn default() -> Self {
163+
WrapAlgorithm::new()
164+
}
161165
}
162166

163167
/// Wrap abstract fragments into lines with a first-fit algorithm.
@@ -341,6 +345,7 @@ mod tests {
341345
#[derive(Debug, PartialEq)]
342346
struct Word(f64);
343347

348+
#[rustfmt::skip]
344349
impl Fragment for Word {
345350
fn width(&self) -> f64 { self.0 }
346351
fn whitespace_width(&self) -> f64 { 1.0 }

src/wrap_algorithms/optimal_fit.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ impl Penalties {
150150
}
151151

152152
impl Default for Penalties {
153-
fn default() -> Self { Self::new() }
153+
fn default() -> Self {
154+
Self::new()
155+
}
154156
}
155157

156158
/// Cache for line numbers. This is necessary to avoid a O(n**2)
@@ -393,6 +395,7 @@ mod tests {
393395
#[derive(Debug, PartialEq)]
394396
struct Word(f64);
395397

398+
#[rustfmt::skip]
396399
impl Fragment for Word {
397400
fn width(&self) -> f64 { self.0 }
398401
fn whitespace_width(&self) -> f64 { 1.0 }

0 commit comments

Comments
 (0)