From 821107122299eebde5da1223ea328f63782ceac9 Mon Sep 17 00:00:00 2001 From: Eskil Queseth Date: Sat, 17 Oct 2020 20:44:54 +0200 Subject: cargo fmt --- mumlib/src/command.rs | 8 ++------ mumlib/src/error.rs | 10 ++++++---- mumlib/src/lib.rs | 2 +- mumlib/src/state.rs | 20 ++++++++++++++------ 4 files changed, 23 insertions(+), 17 deletions(-) (limited to 'mumlib/src') diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs index a216445..e8f4a4d 100644 --- a/mumlib/src/command.rs +++ b/mumlib/src/command.rs @@ -20,10 +20,6 @@ pub enum Command { #[derive(Debug, Deserialize, Serialize)] pub enum CommandResponse { - ChannelList { - channels: Channel, - }, - Status { - server_state: Server, - }, + ChannelList { channels: Channel }, + Status { server_state: Server }, } diff --git a/mumlib/src/error.rs b/mumlib/src/error.rs index cb88aa7..9728f32 100644 --- a/mumlib/src/error.rs +++ b/mumlib/src/error.rs @@ -1,6 +1,6 @@ -use serde::{Serialize, Deserialize}; -use std::fmt::Display; use serde::export::Formatter; +use serde::{Deserialize, Serialize}; +use std::fmt::Display; pub type Result = std::result::Result; @@ -18,7 +18,9 @@ impl Display for Error { Error::DisconnectedError => write!(f, "Not connected to a server"), Error::AlreadyConnectedError => write!(f, "Already connected to a server"), Error::InvalidChannelIdError(id) => write!(f, "Invalid channel id: {}", id), - Error::InvalidServerAddrError(addr, port) => write!(f, "Invalid server address: {}:{}", addr, port), + Error::InvalidServerAddrError(addr, port) => { + write!(f, "Invalid server address: {}:{}", addr, port) + } } } -} \ No newline at end of file +} diff --git a/mumlib/src/lib.rs b/mumlib/src/lib.rs index b77653c..d989a7e 100644 --- a/mumlib/src/lib.rs +++ b/mumlib/src/lib.rs @@ -1,6 +1,6 @@ pub mod command; -pub mod state; pub mod error; +pub mod state; use colored::*; use log::*; diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs index 96598de..b09726e 100644 --- a/mumlib/src/state.rs +++ b/mumlib/src/state.rs @@ -1,6 +1,6 @@ +use serde::export::Formatter; use serde::{Deserialize, Serialize}; use std::fmt::Display; -use serde::export::Formatter; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Server { @@ -24,17 +24,25 @@ impl Channel { pub fn iter(&self) -> Iter<'_> { Iter { me: Some(&self), - channel: if self.children.len() > 0 { Some(0) } else { None }, - channels: self.children.iter().map(|e| e.iter()).collect() + channel: if self.children.len() > 0 { + Some(0) + } else { + None + }, + channels: self.children.iter().map(|e| e.iter()).collect(), } } pub fn users_iter(&self) -> UsersIter<'_> { UsersIter { channels: self.children.iter().map(|e| e.users_iter()).collect(), - channel: if self.children.len() > 0 { Some(0) } else { None }, + channel: if self.children.len() > 0 { + Some(0) + } else { + None + }, user: if self.users.len() > 0 { Some(0) } else { None }, - users: &self.users + users: &self.users, } } } @@ -125,4 +133,4 @@ impl Display for User { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.name) } -} \ No newline at end of file +} -- cgit v1.2.1