From be76c2aa51733a0cf495e92659fbcbe527f41149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 6 Jun 2021 23:26:24 +0200 Subject: cargo fmt --- mumlib/src/command.rs | 13 ++++--------- mumlib/src/config.rs | 4 ++-- mumlib/src/error.rs | 10 ++++++---- mumlib/src/state.rs | 6 +----- 4 files changed, 13 insertions(+), 20 deletions(-) (limited to 'mumlib') diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs index 847b7fd..351d7f6 100644 --- a/mumlib/src/command.rs +++ b/mumlib/src/command.rs @@ -35,7 +35,7 @@ pub enum Command { SendMessage { message: String, targets: Vec, - } + }, } #[derive(Debug, Deserialize, Serialize)] @@ -64,16 +64,11 @@ pub enum CommandResponse { }, PastMessage { message: (String, String), - } + }, } #[derive(Clone, Debug, Deserialize, Serialize)] pub enum MessageTarget { - Channel { - recursive: bool, - name: String, - }, - User { - name: String, - } + Channel { recursive: bool, name: String }, + User { name: String }, } diff --git a/mumlib/src/config.rs b/mumlib/src/config.rs index 587d8d0..1bd3784 100644 --- a/mumlib/src/config.rs +++ b/mumlib/src/config.rs @@ -85,7 +85,7 @@ pub fn default_cfg_path() -> PathBuf { p } //TODO This isn't cross platform. - None => PathBuf::from("/etc/mumdrc") + None => PathBuf::from("/etc/mumdrc"), } } @@ -134,7 +134,7 @@ pub fn read_cfg(path: &Path) -> Result { Ok(s) => { let toml_config: TOMLConfig = toml::from_str(&s)?; Ok(Config::try_from(toml_config)?) - }, + } Err(e) => { if matches!(e.kind(), std::io::ErrorKind::NotFound) && !path.exists() { warn!("Config file not found"); diff --git a/mumlib/src/error.rs b/mumlib/src/error.rs index 459ede0..e88bd97 100644 --- a/mumlib/src/error.rs +++ b/mumlib/src/error.rs @@ -18,14 +18,14 @@ impl std::error::Error for Error {} impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Error::Disconnected=> write!(f, "Not connected to a server"), - Error::AlreadyConnected=> write!(f, "Already connected to a server"), + Error::Disconnected => write!(f, "Not connected to a server"), + Error::AlreadyConnected => write!(f, "Already connected to a server"), Error::ChannelIdentifierError(id, kind) => write!(f, "{}: {}", kind, id), Error::InvalidServerAddr(addr, port) => { write!(f, "Invalid server address: {}: {}", addr, port) } Error::InvalidUsername(username) => write!(f, "Invalid username: {}", username), - Error::InvalidServerPassword => write!(f, "Invalid server password") + Error::InvalidServerPassword => write!(f, "Invalid server password"), } } } @@ -65,7 +65,9 @@ impl fmt::Display for ConfigError { ConfigError::InvalidConfig => write!(f, "Invalid configuration"), ConfigError::TOMLErrorSer(e) => write!(f, "Invalid TOML when serializing: {}", e), ConfigError::TOMLErrorDe(e) => write!(f, "Invalid TOML when deserializing: {}", e), - ConfigError::WontCreateFile => write!(f, "File does not exist but caller didn't allow creation"), + ConfigError::WontCreateFile => { + write!(f, "File does not exist but caller didn't allow creation") + } ConfigError::IOError(e) => write!(f, "IO error: {}", e), } } diff --git a/mumlib/src/state.rs b/mumlib/src/state.rs index 86cbfea..6fad332 100644 --- a/mumlib/src/state.rs +++ b/mumlib/src/state.rs @@ -40,11 +40,7 @@ impl Channel { } else { Some(0) }, - user: if self.users.is_empty() { - None - } else { - Some(0) - }, + user: if self.users.is_empty() { None } else { Some(0) }, users: &self.users, } } -- cgit v1.2.1