error handling cleanup

This commit is contained in:
Michael 2023-02-14 03:27:36 +00:00
parent 4a1ecdee35
commit 2995f6e48b
Signed by: michael
GPG Key ID: 523BD9EF68BDD44C
2 changed files with 5 additions and 9 deletions

View File

@ -29,9 +29,7 @@ impl<'payload> I3msg<'payload> {
IoSlice::new(self.payload.as_bytes()),
];
match self.buffer.write_vectored(bufs) {
Ok(_) => return Ok(self.buffer.to_owned()),
Err(e) => return Err(e),
}
self.buffer.write_vectored(bufs)?;
Ok(self.buffer.to_owned())
}
}

View File

@ -17,10 +17,8 @@ pub struct Sway {
impl Sway {
pub fn new(socket: &str) -> Result<Sway> {
match UnixStream::connect(socket) {
Ok(stream) => return Ok(Sway{stream}),
Err(e) => return Err(e),
};
let stream = UnixStream::connect(socket)?;
Ok(Sway{stream})
}
/// Runs the payload as sway commands
@ -126,7 +124,7 @@ impl Sway {
#[cfg(test)]
mod tests {
use crate::Sway;
use crate::i3msg::*;
use crate::i3msg::I3msg;
use crate::ipc::*;
fn sway_ipc() -> Sway {