Add cargo fmt to .travis.yml (#474)

* Run cargo fmt

* Add cargo fmt to travis.yml
This commit is contained in:
Paul Hauner 2019-07-31 14:45:09 +10:00 committed by GitHub
parent 309b10c4a8
commit 7738d51a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View File

@ -11,6 +11,7 @@ before_install:
- sudo chown -R $USER /usr/local/include/google - sudo chown -R $USER /usr/local/include/google
script: script:
- cargo build --verbose --all --release - cargo build --verbose --all --release
- cargo fmt --all -- --check
rust: rust:
- beta - beta
- nightly - nightly

View File

@ -1,4 +1,4 @@
use std::io::{Write, Result}; use std::io::{Result, Write};
pub const MAX_MESSAGE_WIDTH: usize = 40; pub const MAX_MESSAGE_WIDTH: usize = 40;
@ -17,9 +17,15 @@ impl AlignedTermDecorator {
} }
impl slog_term::Decorator for AlignedTermDecorator { impl slog_term::Decorator for AlignedTermDecorator {
fn with_record<F>(&self, _record: &slog::Record, _logger_values: &slog::OwnedKVList, f: F) fn with_record<F>(
-> Result<()> where &self,
F: FnOnce(&mut dyn slog_term::RecordDecorator) -> std::io::Result<()> { _record: &slog::Record,
_logger_values: &slog::OwnedKVList,
f: F,
) -> Result<()>
where
F: FnOnce(&mut dyn slog_term::RecordDecorator) -> std::io::Result<()>,
{
self.wrapped.with_record(_record, _logger_values, |deco| { self.wrapped.with_record(_record, _logger_values, |deco| {
f(&mut AlignedRecordDecorator::new(deco, self.message_width)) f(&mut AlignedRecordDecorator::new(deco, self.message_width))
}) })
@ -35,8 +41,10 @@ struct AlignedRecordDecorator<'a> {
} }
impl<'a> AlignedRecordDecorator<'a> { impl<'a> AlignedRecordDecorator<'a> {
fn new(decorator: &'a mut dyn slog_term::RecordDecorator, message_width: usize) -> fn new(
AlignedRecordDecorator<'a> { decorator: &'a mut dyn slog_term::RecordDecorator,
message_width: usize,
) -> AlignedRecordDecorator<'a> {
AlignedRecordDecorator { AlignedRecordDecorator {
wrapped: decorator, wrapped: decorator,
message_count: 0, message_count: 0,
@ -103,8 +111,13 @@ impl<'a> slog_term::RecordDecorator for AlignedRecordDecorator<'a> {
fn start_key(&mut self) -> Result<()> { fn start_key(&mut self) -> Result<()> {
if self.message_active && self.message_count + 1 < self.message_width { if self.message_active && self.message_count + 1 < self.message_width {
write!(self, "{}", std::iter::repeat(' ').take(self.message_width - self.message_count) write!(
.collect::<String>())?; self,
"{}",
std::iter::repeat(' ')
.take(self.message_width - self.message_count)
.collect::<String>()
)?;
self.message_active = false; self.message_active = false;
self.message_count = 0; self.message_count = 0;
self.ignore_comma = false; self.ignore_comma = false;