Run cargo fmt with the new Rust stable toolchain (1.31.0)

This commit is contained in:
Karoline Pauls 2018-12-07 15:17:33 +00:00 committed by Florian Dehau
parent a2776dfc86
commit 8522e028f1
19 changed files with 143 additions and 88 deletions

View file

@ -117,9 +117,11 @@ fn main() -> Result<(), failure::Error> {
})?;
match events.next()? {
Event::Input(input) => if input == Key::Char('q') {
Event::Input(input) => {
if input == Key::Char('q') {
break;
},
}
}
Event::Tick => {
app.update();
}

View file

@ -60,7 +60,8 @@ fn main() -> Result<(), failure::Error> {
.fg(Color::White)
.bg(Color::Red)
.modifier(Modifier::Bold),
).render(&mut f, chunks[1]);
)
.render(&mut f, chunks[1]);
}
{
let chunks = Layout::default()
@ -80,9 +81,11 @@ fn main() -> Result<(), failure::Error> {
})?;
match events.next()? {
Event::Input(key) => if key == Key::Char('q') {
Event::Input(key) => {
if key == Key::Char('q') {
break;
},
}
}
_ => {}
}
}

View file

@ -105,7 +105,8 @@ fn main() -> Result<(), failure::Error> {
resolution: MapResolution::High,
});
ctx.print(app.x, -app.y, "You are here", Color::Yellow);
}).x_bounds([-180.0, 180.0])
})
.x_bounds([-180.0, 180.0])
.y_bounds([-90.0, 90.0])
.render(&mut f, chunks[0]);
Canvas::default()
@ -139,7 +140,8 @@ fn main() -> Result<(), failure::Error> {
y2: f64::from(app.ball.top()),
color: Color::Yellow,
});
}).x_bounds([10.0, 110.0])
})
.x_bounds([10.0, 110.0])
.y_bounds([10.0, 110.0])
.render(&mut f, chunks[1]);
})?;

View file

@ -80,7 +80,8 @@ fn main() -> Result<(), failure::Error> {
.title("Chart")
.title_style(Style::default().fg(Color::Cyan).modifier(Modifier::Bold))
.borders(Borders::ALL),
).x_axis(
)
.x_axis(
Axis::default()
.title("X Axis")
.style(Style::default().fg(Color::Gray))
@ -91,14 +92,16 @@ fn main() -> Result<(), failure::Error> {
&format!("{}", (app.window[0] + app.window[1]) / 2.0),
&format!("{}", app.window[1]),
]),
).y_axis(
)
.y_axis(
Axis::default()
.title("Y Axis")
.style(Style::default().fg(Color::Gray))
.labels_style(Style::default().modifier(Modifier::Italic))
.bounds([-20.0, 20.0])
.labels(&["-20", "0", "20"]),
).datasets(&[
)
.datasets(&[
Dataset::default()
.name("data2")
.marker(Marker::Dot)
@ -109,13 +112,16 @@ fn main() -> Result<(), failure::Error> {
.marker(Marker::Braille)
.style(Style::default().fg(Color::Yellow))
.data(&app.data2),
]).render(&mut f, size);
])
.render(&mut f, size);
})?;
match events.next()? {
Event::Input(input) => if input == Key::Char('q') {
Event::Input(input) => {
if input == Key::Char('q') {
break;
},
}
}
Event::Tick => {
app.update();
}

View file

@ -27,7 +27,8 @@ fn main() -> Result<(), failure::Error> {
.title_style(Style::default().fg(Color::Yellow).modifier(Modifier::Bold))
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::Magenta)),
).render(&mut f, size);
)
.render(&mut f, size);
})?;
let input = crossterm::input();

View file

@ -61,9 +61,11 @@ fn main() -> Result<(), failure::Error> {
})?;
match events.next()? {
Event::Input(key) => if key == Key::Char('q') {
Event::Input(key) => {
if key == Key::Char('q') {
break;
},
}
}
_ => {}
}
}

View file

@ -199,9 +199,11 @@ fn main() -> Result<(), failure::Error> {
app.selected -= 1
};
}
Key::Down => if app.selected < app.items.len() - 1 {
Key::Down => {
if app.selected < app.items.len() - 1 {
app.selected += 1;
},
}
}
Key::Left => {
app.tabs.previous();
}
@ -256,7 +258,8 @@ where
Constraint::Length(7),
]
.as_ref(),
).split(area);
)
.split(area);
draw_gauges(f, app, chunks[0]);
draw_charts(f, app, chunks[1]);
draw_text(f, chunks[2]);
@ -281,7 +284,8 @@ where
.fg(Color::Magenta)
.bg(Color::Black)
.modifier(Modifier::Italic),
).label(&format!("{} / 100", app.progress))
)
.label(&format!("{} / 100", app.progress))
.percent(app.progress)
.render(f, chunks[0]);
Sparkline::default()
@ -349,7 +353,8 @@ where
.fg(Color::Black)
.bg(Color::Green)
.modifier(Modifier::Italic),
).label_style(Style::default().fg(Color::Yellow))
)
.label_style(Style::default().fg(Color::Yellow))
.style(Style::default().fg(Color::Green))
.render(f, chunks[1]);
}
@ -360,7 +365,8 @@ where
.title("Chart")
.title_style(Style::default().fg(Color::Cyan).modifier(Modifier::Bold))
.borders(Borders::ALL),
).x_axis(
)
.x_axis(
Axis::default()
.title("X Axis")
.style(Style::default().fg(Color::Gray))
@ -371,14 +377,16 @@ where
&format!("{}", (app.window[0] + app.window[1]) / 2.0),
&format!("{}", app.window[1]),
]),
).y_axis(
)
.y_axis(
Axis::default()
.title("Y Axis")
.style(Style::default().fg(Color::Gray))
.labels_style(Style::default().modifier(Modifier::Italic))
.bounds([-20.0, 20.0])
.labels(&["-20", "0", "20"]),
).datasets(&[
)
.datasets(&[
Dataset::default()
.name("data2")
.marker(Marker::Dot)
@ -389,7 +397,8 @@ where
.marker(Marker::Braille)
.style(Style::default().fg(Color::Yellow))
.data(&app.data3),
]).render(f, chunks[1]);
])
.render(f, chunks[1]);
}
}
@ -420,7 +429,8 @@ where
.borders(Borders::ALL)
.title("Footer")
.title_style(Style::default().fg(Color::Magenta).modifier(Modifier::Bold)),
).wrap(true)
)
.wrap(true)
.render(f, area);
}
@ -476,7 +486,8 @@ where
};
ctx.print(server.coords.1, server.coords.0, "X", color);
}
}).x_bounds([-180.0, 180.0])
})
.x_bounds([-180.0, 180.0])
.y_bounds([-90.0, 90.0])
.render(f, chunks[1]);
}

View file

@ -84,7 +84,8 @@ fn main() -> Result<(), failure::Error> {
Constraint::Percentage(25),
]
.as_ref(),
).split(size);
)
.split(size);
Gauge::default()
.block(Block::default().title("Gauge1").borders(Borders::ALL))
@ -111,9 +112,11 @@ fn main() -> Result<(), failure::Error> {
})?;
match events.next()? {
Event::Input(input) => if input == Key::Char('q') {
Event::Input(input) => {
if input == Key::Char('q') {
break;
},
}
}
Event::Tick => {
app.update();
}

View file

@ -46,7 +46,8 @@ fn main() -> Result<(), failure::Error> {
Constraint::Percentage(10),
]
.as_ref(),
).split(size);
)
.split(size);
Block::default()
.title("Block")
@ -59,9 +60,11 @@ fn main() -> Result<(), failure::Error> {
})?;
match events.next()? {
Event::Input(input) => if let Key::Char('q') = input {
Event::Input(input) => {
if let Key::Char('q') = input {
break;
},
}
}
_ => {}
}
}

View file

@ -52,7 +52,8 @@ fn main() -> Result<(), failure::Error> {
Constraint::Percentage(30),
]
.as_ref(),
).split(size);
)
.split(size);
let text = [
Text::raw("This a line\n"),
@ -83,9 +84,11 @@ fn main() -> Result<(), failure::Error> {
})?;
match events.next()? {
Event::Input(key) => if key == Key::Char('q') {
Event::Input(key) => {
if key == Key::Char('q') {
break;
},
}
}
_ => {}
}
}

View file

@ -16,9 +16,11 @@ fn main() -> Result<(), failure::Error> {
loop {
draw(&mut terminal)?;
match terminal.backend().rustbox().poll_event(false) {
Ok(rustbox::Event::KeyEvent(key)) => if key == Key::Char('q') {
Ok(rustbox::Event::KeyEvent(key)) => {
if key == Key::Char('q') {
break;
},
}
}
Err(e) => panic!("{}", e.description()),
_ => {}
};
@ -41,6 +43,7 @@ fn draw(t: &mut Terminal<RustboxBackend>) -> Result<(), std::io::Error> {
.title_style(Style::default().fg(Color::Yellow).modifier(Modifier::Bold))
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::Magenta)),
).render(&mut f, size)
)
.render(&mut f, size)
})
}

View file

@ -84,13 +84,15 @@ fn main() -> Result<(), failure::Error> {
Constraint::Min(0),
]
.as_ref(),
).split(size);
)
.split(size);
Sparkline::default()
.block(
Block::default()
.title("Data1")
.borders(Borders::LEFT | Borders::RIGHT),
).data(&app.data1)
)
.data(&app.data1)
.style(Style::default().fg(Color::Yellow))
.render(&mut f, chunks[0]);
Sparkline::default()
@ -98,7 +100,8 @@ fn main() -> Result<(), failure::Error> {
Block::default()
.title("Data2")
.borders(Borders::LEFT | Borders::RIGHT),
).data(&app.data2)
)
.data(&app.data2)
.style(Style::default().bg(Color::Green))
.render(&mut f, chunks[1]);
// Multiline
@ -107,15 +110,18 @@ fn main() -> Result<(), failure::Error> {
Block::default()
.title("Data3")
.borders(Borders::LEFT | Borders::RIGHT),
).data(&app.data3)
)
.data(&app.data3)
.style(Style::default().fg(Color::Red))
.render(&mut f, chunks[2]);
})?;
match events.next()? {
Event::Input(input) => if input == Key::Char('q') {
Event::Input(input) => {
if input == Key::Char('q') {
break;
},
}
}
Event::Tick => {
app.update();
}

View file

@ -91,11 +91,13 @@ fn main() -> Result<(), failure::Error> {
app.selected = 0;
}
}
Key::Up => if app.selected > 0 {
Key::Up => {
if app.selected > 0 {
app.selected -= 1;
} else {
app.selected = app.items.len() - 1;
},
}
}
_ => {}
},
_ => {}

View file

@ -379,7 +379,8 @@ fn test_rect_size_truncation() {
// but let's make sure the ratios don't diverge crazily.
assert!(
(f64::from(rect.width) / f64::from(rect.height)
- f64::from(width) / f64::from(height)).abs()
- f64::from(width) / f64::from(height))
.abs()
< 1.0
)
}

View file

@ -154,7 +154,8 @@ impl<'a> Widget for BarChart<'a> {
buf.get_mut(
chart_area.left() + i as u16 * (self.bar_width + self.bar_gap) + x,
chart_area.top() + j,
).set_symbol(symbol)
)
.set_symbol(symbol)
.set_style(self.style);
}

View file

@ -428,7 +428,8 @@ where
for dataset in self.datasets {
match dataset.marker {
Marker::Dot => for &(x, y) in dataset.data.iter().filter(|&&(x, y)| {
Marker::Dot => {
for &(x, y) in dataset.data.iter().filter(|&&(x, y)| {
!(x < self.x_axis.bounds[0]
|| x > self.x_axis.bounds[1]
|| y < self.y_axis.bounds[0]
@ -445,7 +446,8 @@ where
.set_symbol(symbols::DOT)
.set_fg(dataset.style.fg)
.set_bg(dataset.style.bg);
},
}
}
Marker::Braille => {
Canvas::default()
.background_color(self.style.bg)
@ -456,7 +458,8 @@ where
coords: dataset.data,
color: dataset.style.fg,
});
}).draw(graph_area, buf);
})
.draw(graph_area, buf);
}
}
}

View file

@ -236,7 +236,8 @@ impl<'b> Widget for SelectableList<'b> {
} else {
Text::styled(item, self.style)
}
}).skip(offset as usize);
})
.skip(offset as usize);
List::new(items)
.block(self.block.unwrap_or_default())
.style(self.style)

View file

@ -27,7 +27,8 @@ fn it_draws_a_block() {
height: 8,
},
);
}).unwrap();
})
.unwrap();
let mut expected = Buffer::with_lines(vec![
"┌Title─┐ ",
"│ │ ",

View file

@ -28,7 +28,8 @@ fn gauge_render() {
.block(Block::default().title("Ratio").borders(Borders::ALL))
.ratio(0.2113139343131)
.render(&mut f, chunks[1]);
}).unwrap();
})
.unwrap();
let expected = Buffer::with_lines(vec![
" ",
" ",